ScrollView中的中心引力

时间:2016-01-16 21:02:57

标签: android scrollview relativelayout

您好我在ScrollView中居中TextView有问题。我希望将文本视图与hajstextView01textView02垂直居中,以便位于imageViews的高度中心。这很奇怪,因为在Android Studio设计中我看到了一切正确,但是当我尝试使用设备时,我将这些TextView放在TextView的顶部。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:fillViewport="true">

            <RelativeLayout
                android:id="@+id/RelativeLayout1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical|center_horizontal" >

            <TextView
                android:id="@+id/hajs"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/imageView1"
                android:layout_alignParentLeft="true"
                android:layout_alignTop="@+id/imageView1"
                android:layout_centerInParent="true"
                android:layout_toLeftOf="@+id/imageView1"
                android:background="#41BF17"
                android:gravity="center_vertical|center|center_horizontal"
                android:text="0"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFF"
                android:textSize="70sp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:background="#41BF17"
                android:gravity="center"
                android:text="@string/zaoszczedziles"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFF"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/textView2"
                android:adjustViewBounds="true"
                android:background="#41BF17"
                android:maxWidth="100dp"
                android:src="@drawable/moneybag" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/hajs"
                android:background="#41BF17"
                android:gravity="center"
                android:text="@string/dni_bez_papierosow"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFF"
                android:textStyle="bold" />

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/textView3"
                android:adjustViewBounds="true"
                android:background="#41BF17"
                android:maxWidth="100dp"
                android:src="@drawable/calendar" />

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/ImageView01"
                android:layout_alignParentLeft="true"
                android:layout_alignRight="@+id/hajs"
                android:layout_alignTop="@+id/ImageView01"
                android:layout_centerInParent="true"
                android:background="#41BF17"
                android:gravity="center"
                android:text="0"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#FFF"
                android:textSize="70sp" />

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>

0 个答案:

没有答案