添付画像(Photoshopで作成)のように見えるリストビューアイテムのレイアウトを定義しようとしています。どのレイアウトを使用すればよいですか?
4 に答える
1
パディングとマージンを使ってプレイするだけです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/gray_layout"
android:layout_width="40dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#888888"
android:layout_alignParentLeft="true"
android:gravity="center_vertical">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AUG"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="18"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2011"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000088"
android:layout_toRightOf="@id/gray_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/divider"
android:text="Title"
android:layout_marginBottom="5dp"
android:layout_alignBottom="@id/divider"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/divider"
android:text="18. aug 23:49"
android:layout_marginBottom="5dp"
android:layout_alignBottom="@id/divider"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/divider"
android:text="Short msg"
android:layout_marginTop="10dp"
android:layout_alignTop="@id/divider"/>
<ImageView
android:id="@+id/info_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="#ff0000"/>
<ImageView
android:id="@+id/arrow_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_above="@id/info_button"
android:layout_toLeftOf="@id/info_button"
android:background="#00ff00"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/arrow_button"
android:layout_toLeftOf="@id/info_button"
android:layout_alignLeft="@id/arrow_button"
android:gravity="center_horizontal"
android:text="30" />
</RelativeLayout>
于 2013-08-20T23:18:47.803 に答える
1
最初にLinearLayout
水平方向の を提案し、属性を使用して左/上から右/下に他のビューを配置するために a を提案します: 、、など...orientation
RelativeLayout
layout_alignParentTop
layout_alignParentBottom
layout_alignParentLeft
layout_alignParentRight
于 2013-08-20T22:21:20.467 に答える
1
これには a を使用することをお勧めしRelativeLayout
ます。そうしないと、ネストが多すぎる可能性があります。レイアウトを記述するつもりはありませんが、RelativeLayout ドキュメントを調べて、指定できるすべてのプロパティを確認してくださいViews
。あなたもおそらく子になるかもしれませんが、それは問題ありませんLinearLayout
。しかし、私はRelativeLayout
親に使用します。
未定の場合は、xml で非常にすばやく描画して、それぞれがどのように進みViewGroup
、最も効率的であるかを確認することをお勧めします。xml コードまたは少なくともいくつかの疑似コードを作成するまでは、それを言うのが難しい場合があります。
于 2013-08-20T22:21:49.227 に答える