Не удается увидеть всю страницу после запуска приложения в Android

#android #android-layout #android-activity #android-fragments

#Android #android-макет #android-активность #android-фрагменты

Вопрос:

Когда я пытаюсь запустить приложение, я не могу просмотреть всю страницу целиком.Я добавил кнопку #. но видны только две кнопки.Как сделать его совместимым с эмулятором, чтобы я мог видеть все, что есть на страницах.

Вот этот код:

Это мой 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.button.ButtonActivity$PlaceholderFragment" >

    <TextView
        android:id="@ id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="This area is for you to administer the mulitple persons for which you are maintaining records." />



      <Button
            android:id="@ id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="52dp"
            android:text="Add a new Person" />

        <TextView
            android:id="@ id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/textView1"
            android:layout_below="@ id/button1"
            android:layout_marginTop="22dp"
            android:text="Current Person" />

        <Button
            android:id="@ id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/button2"
            android:layout_below="@ id/button2"
            android:layout_marginTop="27dp"
            android:text="Switch To Person" />

        <Button
            android:id="@ id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView2"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Rename Person" />

        <Button
            android:id="@ id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/button3"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Delete This Person" />

    </RelativeLayout>

ManifestFile

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.button"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.button.ButtonActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 

Пожалуйста, предложите что-нибудь..

Комментарии:

1. удалить android:layout_marginTop="27dp" из каждого Button

2. Попробуйте добавить ScrollView в качестве родительского макета.

3. Это будет зависеть от размера экрана, поскольку вы не добавляете вид прокрутки. Чтобы увидеть всю страницу на экране наименьшего размера, вам также необходимо добавить scrollview в родительский.

Ответ №1:

Попробуйте этот способ, надеюсь, это поможет вам решить вашу проблему.

 <ScrollView  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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.button.ButtonActivity$PlaceholderFragment">

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

        <TextView
            android:id="@ id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="This area is for you to administer the mulitple persons for which you are maintaining records." />



        <Button
            android:id="@ id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="52dp"
            android:text="Add a new Person" />

        <TextView
            android:id="@ id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/textView1"
            android:layout_below="@ id/button1"
            android:layout_marginTop="22dp"
            android:text="Current Person" />

        <Button
            android:id="@ id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/button2"
            android:layout_below="@ id/button2"
            android:layout_marginTop="27dp"
            android:text="Switch To Person" />

        <Button
            android:id="@ id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView2"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Rename Person" />

        <Button
            android:id="@ id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/button3"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Delete This Person" />

    </RelativeLayout>
</ScrollView>
 

Ответ №2:

Попробуйте это :

  1. Удалите это :
     android:paddingBottom = "@dimen/activity_vertical_margin"
    android:paddingLeft = "@dimen/activity_horizontal_margin"
    android:paddingRight = "@dimen/activity_horizontal_margin"
    android:paddingTop = "@dimen/activity_vertical_margin"
     

Еще добавьте вид прокрутки к родительскому макету.

Ответ №3:

Попробуйте это!:

 <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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.button.ButtonActivity$PlaceholderFragment" >

    <ScrollView 
    android:id="@ id/scrollViewTopicGrade"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent" >

        <RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
>

    <TextView
        android:id="@ id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="This area is for you to administer the mulitple persons for which you are maintaining records." />



      <Button
            android:id="@ id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView1"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="52dp"
            android:text="Add a new Person" />

        <TextView
            android:id="@ id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/textView1"
            android:layout_below="@ id/button1"
            android:layout_marginTop="22dp"
            android:text="Current Person" />

        <Button
            android:id="@ id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@ id/button2"
            android:layout_below="@ id/button2"
            android:layout_marginTop="27dp"
            android:text="Switch To Person" />

        <Button
            android:id="@ id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/textView2"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Rename Person" />

        <Button
            android:id="@ id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@ id/button3"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="27dp"
            android:text="Delete This Person" />
</RelativeLayout>
    </ScrollView>
    </RelativeLayout>
 

Надеюсь, это может вам помочь