Java android框架布局
我想这样做: 我这样做:Java android框架布局,java,android,Java,Android,我想这样做: 我这样做: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_aplication_settings"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_aplication_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e2e2e2"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.smok.maps.AplicationSettings">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<TextView
android:id="@+id/textSync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/sync" />
<LinearLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textSync">
<TextView
android:id="@+id/actual"
android:layout_width="wrap_content"
android:textColor="#000000"
android:layout_height="wrap_content"
android:text="@string/actual" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/count" />
<TextView
android:id="@+id/actual2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="min" />
</LinearLayout>
<LinearLayout
android:id="@+id/lin2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/line1"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="@xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/point" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="@string/show_choose_point" />
</LinearLayout>
<LinearLayout
android:id="@+id/lin3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lin2"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="@xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/sync" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="@string/sync_request" />
</LinearLayout>
<LinearLayout
android:id="@+id/lin4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lin3"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="@xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/show_chooce" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#000000"
android:gravity="center"
android:text="@string/show_choosen_points" />
</LinearLayout>
<LinearLayout
android:id="@+id/lin5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lin4"
android:orientation="horizontal">
<CheckBox
android:id="@+id/checkBox4"
android:layout_width="50dp"
android:layout_height="50dp"
android:button="@xml/setting_checkbox"
android:focusable="false"
android:gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/position2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"
android:text="@string/current_location" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<Button
android:id="@+id/back_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="@xml/roundedbutton"
android:text="@string/back" />
<View
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent">
</View>
<Button
android:id="@+id/confirm_bt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ffffff"
android:background="@xml/roundedbutton"
android:text="@string/save" />
</LinearLayout>
</RelativeLayout>
我不知道该怎么做。我想做一个边框,在中间我想有地方放文字。这看起来像一个有文本的框架。现在我只有文本,不知道如何创建框架。试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="TEST"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text=" MENU "
android:layout_marginLeft="15dp"
android:background="#ffffff"
android:textSize="17sp" />
</RelativeLayout>
border.xml的xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="3dp"/>
<stroke
android:width="2dp"
android:color="#cdcdcd" />
</shape>
以下是您的需求演示 1) 您需要创建一个border.xml。把这个放在你的绘图文件夹里。在border.xml中添加以下代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--stroke width and color-->
<stroke
android:width="2dp"
android:color="@android:color/darker_gray" />
<!-- corner radius-->
<corners
android:radius="5dp" />
<!--paddings-->
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
2) 以下是layout.xml,将背景相应地设置为线性布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="bd.com.tahsin.myapplicationnavgroup.MainActivity"
tools:showIn="@layout/app_bar_main">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_marginTop="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:background="@drawable/bottom_border_help">
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MENU_BOCZNE"
android:background="@color/background_floating_material_light"
android:layout_marginLeft="10dp" />
</RelativeLayout>
3) 最后是屏幕截图:
希望,这会有所帮助