如何在我的ScrollView末尾放置TextView?

时间:2017-07-04 00:38:48

标签: android android-layout scrollview

我想在ScrollView的底部添加一个TextView,我可以在其中添加版本号。因此,当用户首次进入屏幕时,他们不会看到版本号。向下滚动后,他们可以看到屏幕底部的版本号。我尝试过各种各样的方法,但是没有用。 布局非常嵌套。

This is the screenshot of the layout implementing the code below

enter image description here

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

        <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/linearLayoutThatDoesNotScroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/bg_splash"
                android:clickable="true"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/cnt_full">

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="false"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center">

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_num_trophies_won"
                            style="@style/Theme.App.Text.Headline"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentStart="true"
                            android:layout_marginTop="@dimen/cnt_half"
                            android:drawablePadding="@dimen/cnt_tiny"
                            android:drawableStart="@drawable/icon_trophy"
                            android:fontFamily="thick"
                            android:gravity="center_vertical"
                            android:text="99"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="32sp" />

                        <com.onkore.app.view.FontTextView
                            style="@style/Theme.App.Text.Caption"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_num_trophies_won"
                            android:text="@string/profile_trophies"
                            android:textColor="@color/color_text_primary_inverse" />
                    </RelativeLayout>

                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true">

                        <com.makeramen.roundedimageview.RoundedImageView
                            android:id="@+id/profile_user_pic"
                            android:layout_width="@dimen/profile_image_size"
                            android:layout_height="@dimen/profile_image_size"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            android:src="@drawable/icon_profile_default"
                            app:riv_oval="true" />

                        <com.mikhaellopez.circularprogressbar.CircularProgressBar
                            android:id="@+id/profile_progress_bar"
                            android:layout_width="@dimen/profile_progress_bar_size"
                            android:layout_height="@dimen/profile_progress_bar_size"
                            android:layout_centerHorizontal="false"
                            android:layout_centerInParent="true"
                            android:layout_centerVertical="false"
                            app:cpb_background_progressbar_color="@color/color_base"
                            app:cpb_background_progressbar_width="@dimen/elev_06"
                            app:cpb_progress="25"
                            app:cpb_progressbar_color="@color/color_progress"
                            app:cpb_progressbar_width="@dimen/cnt_tiny" />

                        <com.onkore.app.view.FontTextView
                            android:id="@+id/profile_level"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@id/profile_progress_bar"
                            android:layout_centerHorizontal="true"
                            android:layout_centerInParent="false"
                            android:layout_marginTop="@dimen/cnt_dbl"
                            android:textColor="@color/color_text_primary_inverse"
                            android:textSize="@dimen/text_size"
                            tools:text="Level 99" />

                    </RelativeLayout>

                    <com.onkore.app.view.FontTextView
                        android:id="@+id/profile_okoins"
                        style="@style/Theme.App.Coins.Balance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center_vertical"
                        tools:text="999k" />
                </RelativeLayout>

                <com.onkore.app.view.FontTextView
                    style="@style/Theme.App.Tile.Text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/cnt_full"
                    android:layout_marginStart="@dimen/cnt_full"
                    android:layout_marginTop="@dimen/cnt_full"
                    android:background="@drawable/bg_card_empty"
                    android:gravity="center"
                    android:paddingBottom="@dimen/cnt_dbl"
                    android:paddingTop="@dimen/cnt_part"
                    android:text="Tap to Personalize"
                    android:textAllCaps="true"
                    android:visibility="gone" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/color_primary_translucent"
                    android:visibility="gone">

                    <com.onkore.app.view.FontTextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Friends" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    >

                    <TextView
                        android:id="@+id/versionName"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:background="@color/cardview_dark_background"
                        android:gravity="center_vertical|center_horizontal|center"
                        android:text="HAHA"
                        android:textColor="@color/cardview_light_background"
                        android:visibility="visible" />
                </LinearLayout>
            </LinearLayout>
        </ScrollView>


    </RelativeLayout>

1 个答案:

答案 0 :(得分:0)

也许是这样的?

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

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/linearLayoutThatDoesNotScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorAccent"
            android:clickable="true"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="1000dp" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="version"
                android:textSize="50dp" />

        </LinearLayout>
    </ScrollView>
</RelativeLayout>