2017-12-29 40 views
1

RelativeLayoutCardView、2つはImageViews、シンプルはTextViewのランドスケープレイアウトに取り組んでいます。 Android Studioのプレビューでは、私の望むものとまったく同じように見えますが、実際のデバイスでテストすると、余分なスペースがあるために奇妙に見えます。断片内のRelativelayoutのビューに余分なスペースがあります

これはAndroid Studioのプレビューです: enter image description here

そして、実際のデバイス上でこのように見える:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res 
    /android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    tools:context="de.udacity.dk.cleverdroid.ui.QuizActivity"> 

    <android.support.v7.widget.CardView 
     android:id="@+id/question_and_answers" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/iv_back" 
     android:layout_alignParentTop="true" 
     android:layout_margin="16dp" 
     android:elevation="@dimen/cardview_default_elevation" 
     card_view:cardCornerRadius="8dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center_vertical" 
       android:padding="16dp"> 

       <TextView 
        android:id="@+id/tv_question" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textStyle="bold" 
        tools:text="This is a question" /> 

      </LinearLayout> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="2dp" 
       android:background="@android:color/darker_gray" /> 

      <LinearLayout 
       android:id="@+id/layout_singlechoice" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:padding="16dp"> 

       <RadioGroup 
        android:id="@+id/rg_singlechoice" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 

        <RadioButton 
         android:id="@+id/rb_choice1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         tools:text="Android" /> 

        <RadioButton 
         android:id="@+id/rb_choice2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         tools:text="Android" /> 

        <RadioButton 
         android:id="@+id/rb_choice3" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         tools:text="Android" /> 

        <RadioButton 
         android:id="@+id/rb_choice4" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         tools:text="Android" /> 
       </RadioGroup> 
      </LinearLayout> 
     </LinearLayout> 

    </android.support.v7.widget.CardView> 

    <TextView 
     android:id="@+id/tv_answer" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_toLeftOf="@+id/iv_next" 
     android:layout_toRightOf="@+id/iv_back" 
     android:gravity="center" 
     android:padding="16dp" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" 
     tools:text="This is the answer" 
     tools:textColor="@android:color/black" /> 

    <ImageView 
     android:id="@+id/iv_back" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:background="@drawable/circle_background" 
     android:src="@drawable/ic_keyboard_arrow_left_black_24dp" 
     android:text="@string/quiz_back" 
     android:textColor="@android:color/white" /> 

    <ImageView 
     android:id="@+id/iv_next" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentRight="true" 
     android:background="@drawable/circle_background" 
     android:src="@drawable/ic_keyboard_arrow_right_black_24dp" 
     android:text="@string/quiz_next" 
     android:textColor="@android:color/white" /> 

    </RelativeLayout> 

レイアウトは次のようになります。 enter image description here

ここでは、レイアウトファイルであります私のActivityFragmentコンテナに膨らんでいます。次のようになります。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<include layout="@layout/app_bar" /> 

<FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorBackground"></FrameLayout> 
</LinearLayout> 

私はまず、ActivityAppBarが含まれていると思っていたので、削除しました。しかし、それは問題を解決しません。 この余分なスペースはどこから来たのですか?

+0

RadioGroupのandroid:layout_height = "match_parent"のテストを変更しました。 – MyMy

+0

何も変更されません。 –

答えて

0

私は数時間の頭痛の後にそれを解決しました。 私のActivityでは、私はそのFragmentコンテナに24dpのパディングを持つ間違ったアクティビティレイアウトを指していました。パディングなしで投稿されたアクティビティレイアウトを参照した後、それは動作します。これは本当に簡単な間違いでした。

関連する問題