我想用HorizontalScrollView制作一个新闻报价器。作为第一步,我只是简单地尝试只包含一个Button作为内容的HorizontalScrollView。我希望Button充满整个屏幕,并且Button的文本居中。但到目前为止,Button停留在左侧。以下是代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginTop="50dip"
android:background="#000000"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button 1"
android:textSize="20sp" />
</LinearLayout>
</HorizontalScrollView>
如何解决这个问题?
发布于 2013-03-13 02:58:40
如何解决这个问题?
尝试在HorizontalScrollView上使用fillViewport属性
android:fillViewport="true"https://stackoverflow.com/questions/15366702
复制相似问题