2017-07-04 95 views
0

我想在我的ScrollView的底部添加一個TextView,我可以在其中放置版本號。所以當用戶第一次進入屏幕時,他們看不到版本號。向下滾動後,他們可以在屏幕底部看到版本號。我嘗試了各種方法,不起作用。 佈局相當嵌套。如何在我的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> 
+0

您是否嘗試過對齊文本視圖的父LinearLayout。 android:layout_alignParentBottom =「true」 或將其移動到相對佈局並使其具有:Layout_below –

回答

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> 
相關問題