osi*_*the 7 xml android listview
我想设置Edittext的边框和listview的项目,如图所示:
我的xml代码如下:
<LinearLayout
android:background="#BDD6E0"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:background="#BDD6E0"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Search"
android:textColor="#000000"
android:background="#FFFFFF"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/search_pat_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="#000000"
android:layout_weight="4">
</EditText>
</LinearLayout>
<LinearLayout
android:background="#c0c0c0"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="6" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_weight="1" >
</ListView>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
如何在listview的项目中绘制边框?
Dig*_*tel 16
列表视图的背景
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dip" android:color="@color/edt_focused" />
</shape>
Run Code Online (Sandbox Code Playgroud)
并将属性添加到listview
android:divider="@drawable/list_divider" android:dividerHeight="1px"
Run Code Online (Sandbox Code Playgroud)
将列表子元素的背景设置为
android:background="@drawable/shape"
Run Code Online (Sandbox Code Playgroud)
然后在你的 res>drawable 中创建一个新的shape.xml
像这样
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="2dp"
android:color="#FF000000" />
</shape>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
27192 次 |
最近记录: |