做一个线性布局内框 [英] make a frame inside a linear layout
本文介绍了做一个线性布局内框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想这样做的:
问题是绿框。我不能得到它:
The problem is the green frame. I can't get it:
更新code。与almaz_from_kazan的选择,仍然does not工作:
Update code with almaz_from_kazan choice, still doesnt work:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dip"
android:background="@color/blue"
>
<TextView
android:id="@+id/contactLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:text="@string/aboutTitle"
android:textSize="30dip"
android:layout_marginLeft="10dip"
android:gravity="center"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1.0"
android:background ="@color/red"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".15"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".70"
android:gravity="center"
android:background="@color/green"
/>
//contents
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".15"
/>
</LinearLayout>
</LinearLayout>
我如何能实现帧70%的宽度,70%的高度?
How can I implement the frame 70% width, 70% height?
推荐答案
你可以用你的内容布局
有一些额外的纵向和横向 LinearLayouts
空查看
的做出这样的事情:
You can wrap your content layout
with some extra vertical and horizontal LinearLayouts
with empty View
's and make something like this:
好吧,这里是我的实现。 (但我不认为这是因为空观点的最佳做法)
Ok, here is my implementation. (but i don't think that it is the best practise because of empty view's)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.15" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:orientation="vertical">
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15" />
<!-- content layout -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:background="#0f0" >
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.15" />
</LinearLayout>
这会给你:
绿化面积屏幕宽度刚好70%,屏幕高度的70%
green area is exactly 70% of screen width and 70% of screen height
这篇关于做一个线性布局内框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文