RelativeLayout
はCardView
、2つはImageViews
、シンプルはTextView
のランドスケープレイアウトに取り組んでいます。 Android Studioのプレビューでは、私の望むものとまったく同じように見えますが、実際のデバイスでテストすると、余分なスペースがあるために奇妙に見えます。断片内のRelativelayoutのビューに余分なスペースがあります
これはAndroid Studioのプレビューです:
そして、実際のデバイス上でこのように見える:
<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>
ここでは、レイアウトファイルであります私のActivity
のFragment
コンテナに膨らんでいます。次のようになります。
<?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>
私はまず、Activity
のAppBar
が含まれていると思っていたので、削除しました。しかし、それは問題を解決しません。 この余分なスペースはどこから来たのですか?
RadioGroupのandroid:layout_height = "match_parent"のテストを変更しました。 – MyMy
何も変更されません。 –