And*_*lov 25 android android-layout
这是关于Android布局的问题.这是我急切想要得到的:

深灰色是LinearLayout.橙色是布局X,然后绿色是FrameLayout.我需要将Green放在其父级布局X之外.所描述的布局层次结构不能更改.唯一的选择是布局X - 它可以是你想要的任何东西.
有任何想法吗?
Dar*_*pan 56
使用 -
android:clipChildren="false"
android:clipToPadding="false"
Run Code Online (Sandbox Code Playgroud)
在子视图的每个父视图中,您将视图的"左边距"设置为负视图,这会将您的子视图置于父视图之外,甚至不会剪切视图.
您不能将绿色部分放入布局 X 中,因为它无法在其父级之外绘制。
因此,您应该实现relativelayout或framelayout(根布局)作为所有这些视图的父级。
并将绿色视图作为根布局的子视图。
<?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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14959 次 |
| 最近记录: |