2015-12-28 2 views
0

Хорошо, после попытки любого решения, которое я нашел, я решил разместить свой код здесь для получения справки. Я получаю HTML от JSON, и я помещаю его в TextView, чтобы показать его.Текст Android, отрезанный в нижней части экрана

Это он:

hoursTextView.setText(Html.fromHtml(hours)); 
           hoursTextView.setVisibility(View.VISIBLE); 

Моя проблема в том, что всякий раз, когда содержание выше этого TextView занимает много высоты, я вижу только вырезанные верхние буквы этого TextView и я не могу прокрутить вниз!

Это мой макет XML:

<?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" 
    > 

    <ProgressBar 
     android:id="@+id/loadData" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="50dp" 
     android:layout_centerInParent="true" 
     /> 

    <ImageView 
     android:id="@+id/coverImg" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#000000" 
     android:scaleType="fitCenter" 
     android:adjustViewBounds="true" 
     android:layout_marginBottom="5dp" 
     /> 

    <TextView 
     android:id="@+id/fbAbout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/coverImg" 
     android:gravity="center" 
     /> 

    <View 
     android:id="@+id/seperator" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#eeeeee" 
     android:layout_below="@+id/fbAbout" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="5dp" 
     /> 

    <LinearLayout 
     android:id="@+id/buttons" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/seperator" 
     android:layout_marginStart="5dp" 
     android:layout_marginEnd="5dp" 
     > 

    <TextView 
     android:id="@+id/type" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/beer" 
     android:drawablePadding="5dp" 
     android:text="TYPE" 
     android:layout_weight="1" 
     /> 

    <TextView 
    android:id="@+id/age" 
    android:layout_width="0dp" 
     android:layout_height="70dp" 
    android:background="@drawable/circle_text" 
    android:textAlignment="center" 
    android:gravity="center" 
    android:padding="10dp" 
    android:drawableTop="@drawable/age_big" 
    android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="AGE" 
     android:layout_weight="1" 
    /> 

    <Button 
     android:id="@+id/callToPlace" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/ic_call_black_24dp" 
     android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="CALL" 
     android:layout_weight="1" 
     /> 

    <Button 
     android:id="@+id/nav" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/navigate" 
     android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="navigate" 
     android:layout_weight="1" 
     /> 

    </LinearLayout> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="HOURS" 
     android:id="@+id/hoursTitle" 
     android:layout_below="@+id/buttons" 
     android:layout_centerHorizontal="true" 
     android:visibility="gone" 
     android:layout_marginTop="10dp" 
     /> 
<!--This is the TextView which is cut --> 
    <TextView 
     android:id="@+id/hours" 
     android:layout_marginTop="5dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/hoursTitle" 
     android:visibility="gone" 
     android:layout_centerHorizontal="true" 
     android:gravity="center" 
     /> 

</RelativeLayout> 

Последний TextView, с удостоверением часов, режется на нижней части экрана. Надеюсь, кто-то может мне помочь, спасибо!

+1

добавить (Scrollview) над RelativeLayout. что позволит вам прокручивать, когда содержимое больше физического экрана. http://stackoverflow.com/questions/6674341/how-to-use-scrollview-in-android – Tasos

+0

, если вы хотите прокрутить вниз, вы должны используйте макет прокрутки, например scrollView. Это определенно макет избыточного веса для родителя RelativeLayout .... – Opiatefuchs

ответ

1

Вы можете использовать Scrollview на весь экран.

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/output"> 
    <ProgressBar 
     android:id="@+id/loadData" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="50dp" 
     android:layout_centerInParent="true" 
     /> 

    <ImageView 
     android:id="@+id/coverImg" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#000000" 
     android:scaleType="fitCenter" 
     android:adjustViewBounds="true" 
     android:layout_marginBottom="5dp" 
     /> 

    <TextView 
     android:id="@+id/fbAbout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/coverImg" 
     android:gravity="center" 
     /> 

    <View 
     android:id="@+id/seperator" 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#eeeeee" 
     android:layout_below="@+id/fbAbout" 
     android:layout_marginBottom="5dp" 
     android:layout_marginTop="5dp" 
     /> 

    <LinearLayout 
     android:id="@+id/buttons" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/seperator" 
     android:layout_marginStart="5dp" 
     android:layout_marginEnd="5dp" 
     > 

    <TextView 
     android:id="@+id/type" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/beer" 
     android:drawablePadding="5dp" 
     android:text="TYPE" 
     android:layout_weight="1" 
     /> 

    <TextView 
    android:id="@+id/age" 
    android:layout_width="0dp" 
     android:layout_height="70dp" 
    android:background="@drawable/circle_text" 
    android:textAlignment="center" 
    android:gravity="center" 
    android:padding="10dp" 
    android:drawableTop="@drawable/age_big" 
    android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="AGE" 
     android:layout_weight="1" 
    /> 

    <Button 
     android:id="@+id/callToPlace" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/ic_call_black_24dp" 
     android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="CALL" 
     android:layout_weight="1" 
     /> 

    <Button 
     android:id="@+id/nav" 
     android:layout_width="0dp" 
     android:layout_height="70dp" 
     android:background="@drawable/circle_text" 
     android:textAlignment="center" 
     android:gravity="center" 
     android:padding="10dp" 
     android:drawableTop="@drawable/navigate" 
     android:drawablePadding="5dp" 
     android:layout_marginStart="10dp" 
     android:text="navigate" 
     android:layout_weight="1" 
     /> 

    </LinearLayout> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="HOURS" 
     android:id="@+id/hoursTitle" 
     android:layout_below="@+id/buttons" 
     android:layout_centerHorizontal="true" 
     android:visibility="gone" 
     android:layout_marginTop="10dp" 
     /> 
<!--This is the TextView which is cut --> 
    <TextView 
     android:id="@+id/hours" 
     android:layout_marginTop="5dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/hoursTitle" 
     android:visibility="gone" 
     android:layout_centerHorizontal="true" 
     android:gravity="center" 
     /> 
    </ScrollView> 

Другой пример:

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

    <LinearLayout 

     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 1" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 2" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 3" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 4" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 5" /> 

     <ProgressBar 
      android:id="@+id/progressBar1" 
      style="?android:attr/progressBarStyleHorizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton 1" /> 

     <RadioButton 
      android:id="@+id/radioButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="RadioButton 2" /> 

     <ToggleButton 
      android:id="@+id/toggleButton1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="ToggleButton" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 6" /> 

     <SeekBar 
      android:id="@+id/seekBar1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

     <Button 
      android:id="@+id/button3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 7" /> 

     <Button 
      android:id="@+id/button4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 8" /> 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="CheckBox" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 9" /> 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 10" /> 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Button 11" /> 
    </LinearLayout> 

</ScrollView> 
0

Добавьте вид прокрутки

<ScrollView 
       android:layout_width="match_parent" 
       android:layout_height="150dp" > 
    <!--Just assume it whatever your height is--> 
      <TextView 
       android:id="@+id/hours" 
       android:layout_marginTop="5dp" 
       android:layout_width="wrap_content" 
       android:layout_height="150dp" 
       android:layout_below="@+id/hoursTitle" 
       android:visibility="gone" 
       android:layout_centerHorizontal="true" 
       android:gravity="center" 
       /> 
      </ScrollView> 
Смежные вопросы