Kal*_*n.G 7 android android-emulator android-intent android-layout

嘿伙计我自己第一次尝试实现布局重量,有点我尝试使用线性布局它运行良好,但是当我尝试使用相对和线性布局时出现问题.你们可以告诉我这里有什么问题吗
我的XML文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:id="@+id/Rlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="45" >
<Gallery
android:id="@+id/Gallery01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:spacing="4dip" >
</Gallery>
</RelativeLayout>
<RelativeLayout
android:id="@+id/Rlayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="10"
android:orientation="vertical" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/ImageView02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY" />
</RelativeLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/navbar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="45"
android:background="@drawable/button1"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/makerback"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="20"
android:background="@drawable/makerback" />
<Button
android:id="@+id/makerphoto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="20"
android:background="@drawable/makerphoto" />
<Button
android:id="@+id/makerselves"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="20"
android:background="@drawable/makerselves" />
<Button
android:id="@+id/makerskins"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="20"
android:background="@drawable/makerskins" />
<Button
android:id="@+id/makersave"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="20"
android:background="@drawable/makersave" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我需要实现上面的图像
Sun*_*tya 11
您不能使用百分比来定义RelativeLayout中View的尺寸.最好的方法是使用LinearLayout和权重,或自定义布局.-Roumain Guy
来自文档:http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html#weight
UPDATE
我们现在可以使用PercentRelativeLayout.来自docs的示例:
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%" />
</android.support.percent.PercentFrameLayout>
Run Code Online (Sandbox Code Playgroud)
你不会那样使用重量。尝试
<RelativeLayout
android:layout_height="0dip"
android:layout_weight=1
... />
Run Code Online (Sandbox Code Playgroud)
例如。
| 归档时间: |
|
| 查看次数: |
16041 次 |
| 最近记录: |