Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在横向旋转中被切断的按钮(Android XML)_Android_Xml_Android Layout_Android Dialogfragment_Android Orientation - Fatal编程技术网

在横向旋转中被切断的按钮(Android XML)

在横向旋转中被切断的按钮(Android XML),android,xml,android-layout,android-dialogfragment,android-orientation,Android,Xml,Android Layout,Android Dialogfragment,Android Orientation,当我将屏幕旋转到横向模式时,包含此布局的DialogFragment会切断底部的两个按钮: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android

当我将屏幕旋转到横向模式时,包含此布局的DialogFragment会切断底部的两个按钮:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:padding="4dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Alias"/>

    <EditText
        android:id="@+id/edittext_alias"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapWords"
        android:ems="10"
        android:layout_marginLeft="4dp"
        android:maxLength="30"
        android:imeOptions="actionDone"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Interests"/>

    <EditText
        android:id="@+id/edittext_interests"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:ems="10"
        android:layout_marginLeft="4dp"
        android:maxLength="10"
        android:imeOptions="actionDone"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bio"/>

    <EditText
        android:id="@+id/edittext_bio"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapSentences"
        android:ems="10"
        android:layout_marginLeft="4dp"
        android:maxLines="2"
        android:gravity="top"
        android:imeOptions="actionDone"
        android:requiresFadingEdge="vertical"
        android:fadingEdgeLength="20dp"
        android:scrollbars="vertical"
        android:fadeScrollbars="false"/>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/button_cancel"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Cancel"
            android:layout_weight="1"/>

        <Button
            android:id="@+id/button_confirm"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="OK"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"/>
    </LinearLayout>

</LinearLayout>


我是做错了什么还是遗漏了一些明显的东西?我怎样才能让它强制显示所有内容?

我认为情况是您的屏幕不够大,无法显示全部内容。如果内容比屏幕大,Android不会添加滚动功能。如果是这种情况,请将所有视图包装在
滚动视图中
,以便在滚动后可以看到按钮。像这样:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:padding="4dp"> 

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <!-- Putt all your view here -->

        </LinearLayout>
    </ScrollView>
</LinearLayout>

您也可以将ScrollView作为父视图

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

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

            <!-- Putt all your view here -->

        </LinearLayout>
    </ScrollView>


能否显示包含
片段的布局XML?您可能需要为横向方向创建专用布局。然后将这样一个布局文件放入
res/layout land
中。它是一个对话框片段,因此它自己漂浮在屏幕上方。此布局已在
res/layout land
中实施。