Android 根据屏幕大小自动收缩文本视图

Android 根据屏幕大小自动收缩文本视图,android,Android,我正试图让TextView根据设备屏幕大小进行包装,以便底部的3按钮在屏幕底部始终可见 我尝试了来自的解决方案,但ScrollView似乎不起作用。3个按钮不可见 这是我的密码。谢谢你的阅读 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertic

我正试图让TextView根据设备屏幕大小进行包装,以便底部的3按钮在屏幕底部始终可见

我尝试了来自的解决方案,但ScrollView似乎不起作用。3个按钮不可见

这是我的密码。谢谢你的阅读

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:fillViewport="true">
        <TextView
            android:text="@string/default_tnc"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"     
            android:layout_weight="1.0"/>
    </ScrollView>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_alignParentBottom="true">
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button 1"/>
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button 2"/>
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button 3"/>
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

将android:layout\u weight=“1”添加到您的
滚动视图中
,并将滚动视图的高度更改为0
文本视图中删除android:layout_weight=“1”

<ScrollView
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:scrollbars="vertical"
            android:layout_weight="1.0"
            android:fillViewport="true">
            <TextView
                android:text="@string/default_tnc"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" // or wrap_content     
                />
  </ScrollView>


希望有此帮助

这是您需要的,只需复制并粘贴即可

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"
    android:layout_above="@+id/ll_layout"
    android:padding="10dp"
    android:layout_weight=".8">
    <TextView
        android:text="@string/temp_txt"
        android:textColor="@android:color/black"
        android:background="@android:color/white"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        />
   </ScrollView>


    <LinearLayout
        android:layout_width="match_parent"
        android:id="@+id/ll_layout"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:layout_weight="1"
            android:text="Button 1"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:layout_weight="1"
            android:text="Button 2"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="20dp"
            android:text="Button 3"/>
    </LinearLayout>
</RelativeLayout>

您可以使用

<?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:context=".lActivity">

<ScrollView
    android:id="@+id/web_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<TextView 
// enter code here
/>
</CrollView>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_alignParentBottom="true"
    android:background="#FFFFFF">

  <Button>
  <Button>
  <Button>

</RelativeLayout>

</RelativeLayout>

不要使用
线性布局
作为主父级,只需使用
相对布局
。然后只需使用ScrollView中的
layout_over
属性,将其设置为位于屏幕上方

ativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”>

了解更多有关如何使用RelativeLayouts的信息。你可以查看Android开发者官方网站--。希望这有帮助。:)

只需使用
RelativeLayout
作为父布局即可。
ativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/id_rl_below"
        android:layout_alignParentTop="true"
        android:scrollbars="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1.0"
            android:text="asdhgfahgdsashgaweatlweiutnwaueytluwae ytbluwae ytbluewzybltuewzsyb tzsydgzlu ybeutzybwlutvybwelutyvzewuiybtuwzey btuzwey tluiwg usdbugdslyuggjzsg zsdg sd mgzsdnzsntzsetxseyuxtrutfru xtfrunftu nxut uctr mxr untrxuxdumtrrumxrtmuxrumnrxtumn"
            android:textSize="50dp" />

    </ScrollView>

    <LinearLayout
        android:id="@id/id_rl_below"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

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

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

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

    </LinearLayout>

</RelativeLayout>