我正在尝试创建一个由 EditText 和 Button 小部件组成的简单 Android UI。但是我在设置布局属性时遇到了一些问题。用户界面应该是这样的:
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
左边是 EditText,右边是 Button。按钮 (ImageButton) 的宽度约为 50x50,我想将其固定。然而,TextBox 应该跨越按钮的整个可用空间,但我无法让它工作。我想让这项工作动态进行,这样我就不必为不同的屏幕尺寸或方向指定不同的布局(如果可能的话)。
这是我的第一个 Android 应用程序,所以我很感激任何有关如何最好地构建应用程序 UI 的建议。
谢谢,
b3n
最佳答案
这应该按照您的需要放置元素。
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<TextView
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="text"/>
<Button
android:id="@+id/b1"
android:text="test"
android:layout_height="50px"
android:layout_width="50px"
/>
关于android-widget - 在 Android UI 上动态扩展小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3877332/