我有一个简单的XML我试图膨胀,并与布局挣扎。我想要实现的是非常简单的(或者我认为),所以我确信我错误地做了这件事。基本上我有三个元素,2个TextViews和一个Imageview。我希望两个文本框放在一起,右边的图像对齐右侧,其视图将它与图像的大小相匹配。就像这样:将布局设置为其内容的大小
Text 1 |==|
Text 2 would be below text 1 |==|
我的继承人XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/entry_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingRight="?android:attr/scrollbarSize" >
<LinearLayout
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/entry1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:gravity="left"
android:paddingLeft="@dimen/tab_host_default_height"
android:text="@string/test_string"
android:textStyle="bold" />
<TextView
android:id="@+id/entry2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="@string/test_string" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<ImageButton
android:id="@+id/entry3"
style="@style/ImageButtonBDTheme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/activated_background_holo_light"
android:contentDescription="@string/click_for_repair_report"
android:paddingRight="5dp"
android:src="@drawable/entry_link" />
</LinearLayout>
</LinearLayout>
问题是,我不能要显示的图像没有硬编码包含两个文本框的LinearLayout的大小。
任何帮助表示赞赏!
你明白了!感谢您的快速回复:) – xceph
你可能可以解释这是如何工作的?我会认为在一个中设置权重,但不是另一个只会显示该元素。 – xceph
什么尺寸是需要显示imagebutton它将采取和其余的大小是由textview布局使用.. –