Str*_*ing 98 android listview android-intent android-layout
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Twitter Feeds"
android:textStyle="bold" />
<ListView
android:id="@+id/list"
android:layout_width="350dp"
android:layout_height="50dp" />
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:text="FaceBook Feeds" />
<ListView
android:id="@+id/list1"
android:layout_width="350dp"
android:layout_height="50dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的要求是在和之间绘制一条水平线TextViewListView
有人可以帮忙吗?
Bho*_*att 261
它将在TextView&之间绘制银灰色线条ListView
<TextView
android:id="@+id/textView1"
style="@style/behindMenuItemLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:text="FaceBook Feeds" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#c0c0c0"/>
<ListView
android:id="@+id/list1"
android:layout_width="350dp"
android:layout_height="50dp" />
Run Code Online (Sandbox Code Playgroud)
vov*_*ost 21
您应该使用新的轻量级View Space来绘制分隔线.如果您将使用Space而不是,您的布局将加载更快View.
水平分隔线:
<android.support.v4.widget.Space
android:layout_height="1dp"
android:layout_width="match_parent" />
Run Code Online (Sandbox Code Playgroud)
垂直分隔线:
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp" />
Run Code Online (Sandbox Code Playgroud)
您还可以添加背景:
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
Run Code Online (Sandbox Code Playgroud)
用法示例:
....
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="One"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two"/>
<android.support.v4.widget.Space
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="?android:attr/listDivider"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three"/>
....
Run Code Online (Sandbox Code Playgroud)
要使用,Space您应该在build.gradle中添加依赖项:
dependencies {
compile 'com.android.support:support-v4:22.1.+'
}
Run Code Online (Sandbox Code Playgroud)
文档https://developer.android.com/reference/android/support/v4/widget/Space.html
zoz*_*lfo 20
在您要分隔的视图之间的布局中添加这样的内容:
<View
android:id="@+id/SplitLine_hor1"
android:layout_width="match_parent"
android:layout_height= "2dp"
android:background="@color/gray" />
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你 :)
one*_*exf 12
创建一次并在需要的地方使用它是一个好主意.在styles.xml中添加:
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并在需要行分隔符的xml代码中添加:
<View style="@style/Divider"/>
Run Code Online (Sandbox Code Playgroud)
最初由toddles_fp回答这个问题:布局中的Android绘图分隔符/分隔线?
Xam*_*Xam 10
多年后,终于有了一个合适的视图来在 XML 布局上显示分隔符/分隔符/水平线。为 Android 开发 Material Components 的团队已经发布了版本 1.5.0-alpha01,其中添加了该类MaterialDivider。如前所述,这允许向布局添加分隔线。
首先,在 build.gradle 中添加以下内容:
implementation 'com.google.android.material:material:1.5.0-alpha01'
然后,在 XML 布局上您可以编写:
<com.google.android.material.divider.MaterialDivider
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)
瞧,你有一个分隔器。如果你想自定义分隔线的颜色,有一个xml属性:app:dividerColor。此视图还允许通过样式设置主题。欲了解更多信息,您可以查看此链接。
试试这个
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="?android:attr/listDivider"/>
Run Code Online (Sandbox Code Playgroud)
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
163947 次 |
| 最近记录: |