2017-03-02 3 views
-1

Ich möchte, dies zu tun: enter image description hereJava Android-Frame-Layout

Ich tat dies:

<?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> 

Ich habe keine Ahnung, wie ich Grenze tun können. Ich möchte eine Grenze machen und in der Mitte möchte ich Platz haben, um Text zu setzen. Das gleiche wie auf dem Bildschirm. Das sieht wie ein Rahmen aus, der einen Text hat. Jetzt habe ich onli Text und ich kann nicht wie ich einen Rahmen erstellen kann. diese

Antwort

1

Hier Demo von Ihrer Anforderung.

1) Sie müssen eine border.xml erstellen. Legen Sie dies in Ihren aufklappbaren Ordner. Fügen Sie den folgenden Code in 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) Hier ist die layout.xml den Hintergrund zu einer Linearlayout entsprechend gesetzt ist:

<?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) Und schließlich der Bildschirm-shot:

enter image description here

Hoffe, das wird ein wenig helfen.

1

Versuchen,

 <?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> 

xml von border.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>