I want to make a news ticker using a HorizontalScrollView
. As a first step, I am simply trying out the HorizontalScrollView
which contains only a Button
as the content. I want the Button
to fill the entire screen and the Button
's text to be centered. But so far, the Button
is stuck on the left side. Here is the code:
<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>
How to solve this problem?
How to solve this problem?
Try to use the fillViewport
attribute on the HorizontalScrollView
:
android:fillViewport="true"