Joe*_*ing 1 xml layout android view
为了构建应用程序,我们有几个列表.列表项存在问题,这是自定义的,但非常简单.格式为:
这表示一个列表项,包含2个textviews和一个图像视图
请注意,标题和日期实际上位于彼此之下,图像位于右侧,中心垂直为属性.图像不应位于两个文本视图之间
我先给出XML,然后解释确切的问题.
XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:textSize="16dip"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:textSize="12dip"
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="5dip" >
<ImageView
android:id="@+id/validationStateImg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
问题: 在某种意义上,此布局显示的内容与ascii表示完全相同.什么不能正常工作是文本变长.如果文本很长,但不足以占用2行,则只会使图像视图变小.
在其他情况下,它只是将imageview完全推离屏幕..
我需要的是,当日期或其他文本视图的长度太长时,要打破一个新行.当然,它需要是一种可移植到各种屏幕尺寸的解决方案.
我不是UI艺术家,所以,如果我滥用布局,不应该使用它们,请道歉.
除了帮助,提示和提示也欢迎!
我认为你最好的选择是一个简单的RelativeLayout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<ImageView
android:id="@+id/validationStateImg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/validationStateImg"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="16dp"
/>
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/validationStateImg"
android:layout_alignParentLeft="true"
android:layout_below="@id/title"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
将ImageView捕捉到父级的右侧,让TextViews占据宽度的其余部分,但是与ImageView的左侧对齐.
归档时间: |
|
查看次数: |
3347 次 |
最近记录: |