2016-07-22 33 views
0

enter image description here 我已經上傳了問題的截圖,請檢查... textview中的文本和按鈕會獲取彼此。我已經使用HTML文本和滾動條爲它.....請幫助!文本和按鈕獲取覆蓋.....我想固定在文本視圖底部的按鈕

這裏是我的代碼:

XML:

<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" 
android:background="@drawable/images" 
tools:context="com.example.acer.aartisangrah.alaganraya"> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center"> 
    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:gravity="center" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 
</ScrollView> 

<Button 
    android:id="@+id/b2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:onClick="decrease" 
    android:text="Decrease" /> 

<Button 
    android:id="@+id/b1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:onClick="increase" 
    android:text="Increase" /> 
</RelativeLayout> 

這裏文本視圖我用HTML

CODE:

tv=(TextView)findViewById(R.id.textView4); 
tv.setTextSize((float) 18.0); 
tv.setText(Html.fromHtml(getString(R.string.five))); 

請注意,文字的TEXTSIZE在文本視圖中可以增加或減少....

+0

檢查圖像 – Devk

回答

0

使您的代碼是這樣的:

<LinearLayout 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" 
android:background="@drawable/images" 
android:orientation="vertical" 
tools:context="com.example.acer.aartisangrah.alaganraya"> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:gravity="center"> 

    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 
</ScrollView> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <Button 
     android:id="@+id/b2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:onClick="decrease" 
     android:text="Decrease" /> 

    <Button 
     android:id="@+id/b1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:onClick="increase" 
     android:text="Increase" /> 
</RelativeLayout> 

+0

檢查圖像 – Devk

+0

你有使用我放置的代碼嗎? –

+0

對不起.... dint讓你 – Devk

2

這是因爲您尚未指定視圖的對齊順序。

例如:您可以使用android:layout_above="@+id/btn"android:layout_below="@+id/scrollbar來安排視圖。

+0

檢查圖像 – Devk

+0

放在這兩個在的LinearLayout按鈕/ RelativeLayout(名稱id爲btnLayout)。添加'android:layout_above =「@ + id/btnLayout」到滾動視圖 –