RelativeLayout with scrollview not scrolling

前端 未结 3 1698
时光说笑
时光说笑 2021-01-18 06:26

I\'m working on fixing a bug in someone\'s code and I can\'t figure out how to get this to scroll correctly. I\'m just trying to get the \"question\" area to scroll vertical

相关标签:
3条回答
  • 2021-01-18 07:23

    If you do not want to set it to a specific height, you can also add

    android:fillViewport="true"
    

    to your ScrollView

    0 讨论(0)
  • 2021-01-18 07:27

    Your scroll view doesn't have any problem. But, You can not see your scroll bar because your textview has too short text.

    Update your code like below.

    Scroll bar will be shown up when contents are long than yours automatically.

    Good luck, Josh!

    <ScrollView android:layout_height= " fill_parent "
        android:layout_toRightOf="@+id/q" android:layout_marginTop="10dp"
        android:layout_width="150dp">
    
        <TextView android:id="@+id/question"
            android:text="Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a Test annswer a ....."
            android:layout_height="fill_parent"
            android:layout_toRightOf="@+id/q" android:layout_marginTop="10dp"
            android:layout_width="150dp" android:textColor="#000000"
            android:textSize="18sp" android:textStyle="bold" />
    </ScrollView>
    
    0 讨论(0)
  • 2021-01-18 07:29

    That is because you set the height of the ScrollView to wrap_content. Try giving it a fixed height or using a LinearLayout with weight so it fills the space left over from the other views.

    0 讨论(0)
提交回复
热议问题