[英]How to draw line on Linear Layout?
如何在LinearLayout
上畫線? 我進行了搜索,但沒有找到答案; /我知道如何在EditView
和TextView
上繪制這條線,但不能在LinearLayout
上畫這條線,可能嗎?
我嘗試創建新視圖(horizontal_line)並添加到我的LinearLayout
但這是錯誤的想法。
嘗試這個:-
<View
android:layout_width="fill_parent"
android:layout_weight="2"
android:layout_height="0.5dip"
android:layout_marginTop="0.5dp"
android:background="#E6E6E6"/>
您可以在Xaml中創建視圖,它會創建一條垂直線,因此您需要更改高度和寬度
<View
android:id="@+id/verticalSeparator"
android:layout_width="1dp"
android:layout_height="100dp"
android:background="#000000"
android:layout_toRightOf="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
如果定位到Honeycomb或更高版本,則可以使用setShowDividers()
和setDividerDrawable()
方法。
如果您不使用Xaml而僅使用c#,則答案為:
LinearLayout scrollContainer = new LinearLayout(Application.Context);
scrollContainer.Orientation = Orientation.Vertical;
View line = new View(Application.Context);
line.Id = 1;
line.SetBackgroundColor(Android.Graphics.Color.DarkGray); // the color you want
line.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 2); // 2 is the height you want
scrollContainer.AddView(line);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.