【发布时间】:2011-04-07 17:56:36
【问题描述】:
我真的在为我的应用程序中的一部分布局而苦苦挣扎。我有一个带有居中图像的标题栏,右侧应该有两个按钮(或像我现在拥有的可点击图像)。我设法让图像彼此相邻(全部居中),但我想要右边的图像。当我使用 layout_weight 进行“第一个”拉伸时,按钮在右侧,但它们变得如此之小。我希望按钮(图像)保持其原始大小。我什至尝试使用 minWidth 和 minHeight 对其进行硬编码,但这不起作用。
以下是所有内容的中心代码:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/header_tile">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/header_logo">
</ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/previous"
android:src="@drawable/omhoog"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<ImageView
android:id="@+id/next"
android:src="@drawable/omlaag"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
</LinearLayout>
下面是有效的代码,只是最后一张图片变得太小了:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/header_tile">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/header_logo"
android:layout_weight="2">
</ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="@+id/previous"
android:src="@drawable/omhoog"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<ImageView
android:id="@+id/next"
android:src="@drawable/omlaag"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
</LinearLayout>
有什么想法吗?非常感谢!
埃里克
【问题讨论】: