Androidのレイアウトについての質問です。これが私が熱心に手に入れたいものです:
ダークグレーはLinearLayoutです。オレンジはレイアウトXで、緑はFrameLayoutです。Greenをその親の外側に配置する必要があります-レイアウトX。説明されているレイアウト階層は変更できません。唯一のオプションはレイアウトXです-それはあなたが望むものなら何でもかまいません。
何か案は?
Androidのレイアウトについての質問です。これが私が熱心に手に入れたいものです:
ダークグレーはLinearLayoutです。オレンジはレイアウトXで、緑はFrameLayoutです。Greenをその親の外側に配置する必要があります-レイアウトX。説明されているレイアウト階層は変更できません。唯一のオプションはレイアウトXです-それはあなたが望むものなら何でもかまいません。
何か案は?
使用する -
android:clipChildren="false"
android:clipToPadding="false"
子ビューのすべての親で、ビューの「左マージン」を負に設定します。これにより、子ビューが親ビューの外側に配置され、ビューがクリップされることもありません。
緑の部分は親の外に描画できないため、レイアウトXに配置することはできません。
したがって、これらすべてのビューの親として、RelativeLayoutまたはFrameLayout(ルートレイアウト)を実装する必要があります。
そして、グリーンビューをルートレイアウトのchildViewとして配置します。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/layout_dark_grey"
android:layout_width="100dp"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/layout_orange"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/layout_dark_grey"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:id="@+id/layout_green"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="300dp" >
</RelativeLayout>
</RelativeLayout>
android:clipChildren="false"
親レイアウトに追加するだけです。
<?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="horizontal"
android:clipChildren="false">
<LinearLayout
android:layout_marginLeft="-25dp"
android:background="@color/colorGray"
android:layout_width="100dp"
android:layout_height="100dp"/>
<LinearLayout
android:gravity="center|left"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="@color/colorOrange">
<LinearLayout
android:layout_marginLeft="-25dp"
android:background="@color/colorGreen"
android:layout_width="50dp"
android:layout_height="50dp"></LinearLayout>
</LinearLayout>
</LinearLayout>