下面是我的xml,我想将button1设置为左中央垂直,button2设置为右中央垂直,但对于我来说,android:layout_gravity="center_vertical|right"不工作,有什么问题吗?我知道我可以通过使用填充物或毛边来实现这一点,但我不知道为什么它不起作用。我该怎么做呢?
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:layout_gravity="center_vertical"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
android:layout_gravity="center_vertical|right"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</RelativeLayout>
</FrameLayout>
</HorizontalScrollView>发布于 2011-02-03 05:52:26
在这里,您的问题是当您使用HorizontalScrollView时,结果是FrameLayout无法使其宽度达到fill_parent.If,您将移除所需的HorizontalScrollView,我认为这将得到所需的结果。
发布于 2011-10-24 21:41:46
是的,如果您将HorizontalScrollView替换为LinearLayout,那么您将看到所需的效果。
https://stackoverflow.com/questions/4882778
复制相似问题