2017-02-18 4 views
0

私は、フラグメントとボタンをホストするアクティビティを持っていますが、ボタンはスクリーンの下部の小さな部分を取る必要があります。 しかし、相対レイアウトを縮小して、ボタンがフラグメントに重ならないようにすることはできません。以下 相対レイアウトのビューが小さい画面で縮小しない

は、私の活動のレイアウト

<?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:id="@+id/activity_registration" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical" 
    tools:context="com.example.activities.RegistrationActivity"> 

    <fragment 
     android:name="com.example.fragments.registration.GenderFragment" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     tools:layout="@layout/fragment_gender" /> 

    <Button 
     android:id="@+id/profile_progress_bar" 
     android:layout_width="match_parent" 
     android:layout_height="60dp" 
     android:background="@color/colorPrimary" 
     android:text="BUTTON TEXT" 
     android:textColor="@android:color/holo_red_dark" /> 

</LinearLayout> 

であり、以下、それは

demo

答えて

0

あなたfrangmentをどのように見えるのスクリーンショットは、フラグメント以下

<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="wrap_content" 
    tools:context="com.example.fragments.registration.GenderFragment"> 

    <ImageView 
     android:id="@+id/welcome_note" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="@dimen/xlarge_top_margin" 
     android:src="@drawable/bienvenido" /> 

    <TextView 
     android:id="@+id/gender_explanation" 
     style="@style/HeaderTitleWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/welcome_note" 
     android:layout_centerHorizontal="true" 
     android:text="WELCOME TO THE APP" 
     android:textSize="@dimen/header_title_text_view_xtra_big_size" /> 

    <LinearLayout 
     android:id="@+id/gender_avatar_holder" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/gender_explanation" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/medium_top_margin" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/female" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/woman" 
      android:scaleType="centerInside" /> 


     <ImageView 
      android:id="@+id/male" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/man" 
      android:scaleType="centerInside" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/next" 
     style="@style/AppButtonMedium" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_alignEnd="@+id/gender_explanation" 
     android:layout_alignLeft="@+id/gender_explanation" 
     android:layout_alignRight="@+id/gender_explanation" 
     android:layout_alignStart="@+id/gender_explanation" 
     android:layout_below="@+id/gender_avatar_holder" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/large_top_margin" 
     android:text="NEXT" 
     android:textStyle="normal|bold" /> 

</RelativeLayout> 

のレイアウトされていますコンテンツが大きすぎるため、レイアウト内でScrollViewを使用する必要があります、 このような。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 

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

<RelativeLayout xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    tools:context="com.example.fragments.registration.GenderFragment"> 

    <ImageView 
     android:id="@+id/welcome_note" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="@dimen/xlarge_top_margin" 
     android:src="@drawable/bienvenido" /> 

    <TextView 
     android:id="@+id/gender_explanation" 
     style="@style/HeaderTitleWhite" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/welcome_note" 
     android:layout_centerHorizontal="true" 
     android:text="WELCOME TO THE APP" 
     android:textSize="@dimen/header_title_text_view_xtra_big_size" /> 

    <LinearLayout 
     android:id="@+id/gender_avatar_holder" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/gender_explanation" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/medium_top_margin" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/female" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleType="centerInside" 
      android:src="@drawable/woman" /> 


     <ImageView 
      android:id="@+id/male" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleType="centerInside" 
      android:src="@drawable/man" /> 

    </LinearLayout> 

    <Button 
     android:id="@+id/next" 
     style="@style/AppButtonMedium" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_alignEnd="@+id/gender_explanation" 
     android:layout_alignLeft="@+id/gender_explanation" 
     android:layout_alignRight="@+id/gender_explanation" 
     android:layout_alignStart="@+id/gender_explanation" 
     android:layout_below="@+id/gender_avatar_holder" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="@dimen/large_top_margin" 
     android:text="NEXT" 
     android:textStyle="normal|bold" /> 

</RelativeLayout> 

+0

OK、相対的なレイアウトのコンテンツが収まるように縮小させるための方法でscrollviewせずにこの作品を作るための方法はありますか? – Fouad

+0

@Fouadはすべての密度のレイアウトを作成する方法です。 –

+0

あなたは、異なる画面サイズに対して異なるレイアウトを作成するか、またはdpとsp単位を使用する必要がありますか? – Fouad

関連する問題