我想制作像附加图像的边框

时间:2016-06-08 11:40:52

标签: android

screen 3rd

我想在我的应用中制作像附加图像的边框。请帮帮我。 原始屏幕与下面的代码相同。 我想制作第一个屏幕图像。告诉我xml的变化。 如何制作像scereen图像的边框?

customborder.xml

UIAlertController * alert=   [UIAlertController
                                  alertControllerWithTitle:[[[NSBundle mainBundle] infoDictionary]
                                                            objectForKey:@"CFBundleDisplayName"]
                                  message:@"share via"
                                  preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction* fbButton = [UIAlertAction
                                actionWithTitle:@"Facebook"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction * action)
                                {
                                    // Add your code
                                }];
    UIAlertAction* twitterButton = [UIAlertAction
                                   actionWithTitle:@"Twitter"
                                   style:UIAlertActionStyleDefault
                                   handler:^(UIAlertAction * action)
                                   {
                                       // Add your code

                                   }];
    UIAlertAction* watsappButton = [UIAlertAction
                                    actionWithTitle:@"Whatsapp"
                                    style:UIAlertActionStyleDefault
                                    handler:^(UIAlertAction * action)
                                    {
                                      // Add your code
                                    }];
    UIAlertAction* emailButton = [UIAlertAction
                                    actionWithTitle:@"Email"
                                    style:UIAlertActionStyleDefault
                                    handler:^(UIAlertAction * action)
                                    {

                                        // Add your code
                                    }];
    UIAlertAction* cancelButton = [UIAlertAction
                                  actionWithTitle:@"Cancel"
                                  style:UIAlertActionStyleDefault
                                  handler:^(UIAlertAction * action)
                                  {
                                      //Handel no, thanks button

                                  }];

    [alert addAction:fbButton];
    [alert addAction:twitterButton];
    [alert addAction:watsappButton];
    [alert addAction:emailButton];
    [alert addAction:cancelButton];

    [self presentViewController:alert animated:YES completion:nil];

2 个答案:

答案 0 :(得分:1)

将此xml添加到drawable文件夹

<强> bdr_top.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="-2dp"
    android:left="-2dp"
    android:right="-2dp"
    android:top="2dp">
    <shape android:shape="rectangle" >
        <stroke
            android:width="2dp"
            android:color="#009bdb" />

        <solid android:color="#00FFFFFF" />

        <padding android:left="0dp"
            android:right="0dp"
            android:top="0dp"
            android:bottom="0dp" />
    </shape>
</item>

</layer-list>

<强> bdr_top_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="-1dp"
    android:left="-1dp"
    android:right="-1dp"
    android:top="1dp">
    <shape android:shape="rectangle" >
        <stroke
            android:width="1dp"
            android:color="#7e7e7e" />

        <solid android:color="#00FFFFFF" />

        <padding android:left="0dp"
            android:right="0dp"
            android:top="0dp"
            android:bottom="0dp" />
    </shape>
</item>

</layer-list>

<强> bdr_all.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="1dp"
    android:left="1dp"
    android:right="1dp"
    android:top="1dp">
    <shape android:shape="rectangle" >
        <stroke
            android:width="1dp"
            android:color="#7e7e7e" />

        <solid android:color="#00FFFFFF" />

        <padding android:left="0dp"
            android:right="0dp"
            android:top="0dp"
            android:bottom="0dp" />
    </shape>
</item>

</layer-list>

你的xml替换它

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llParent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bdr_top"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="10dip">

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="20dp"
    android:background="@drawable/bdr_all">


    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#7e7e7e"
        android:orientation="horizontal"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView1"
            android:text="Order Id:" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:padding="5dip"
            android:text="Placed Date:"></TextView>

    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView3"
            android:text="Address:" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView4"
            android:text="Placed Order:" />

        <TextView
            android:id="@+id/placedorder"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView5"
            android:text="Service Opted: " />

        <TextView
            android:id="@+id/serviceopted"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView6"
            android:text="Order Status:" />

        <TextView
            android:id="@+id/orderstatus"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView7"
            android:text="Time Slot:" />

        <TextView
            android:id="@+id/timeslot"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/bdr_top_bottom"
        android:orientation="vertical"
        android:padding="10dip">

        <TextView
            android:id="@+id/textView8"
            android:text="Contact Number:" />

        <TextView
            android:id="@+id/contactno"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1"
            android:text="8556023080" />
    </TableRow>


</TableLayout>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:orientation="horizontal"
    android:padding="6dp"
    android:weightSum="2">

    <Button
        android:id="@+id/repeat"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="20dp"
        android:layout_weight="1"
        android:background="#009bdb"
        android:text="Repeat Order"
        android:textColor="#FFFFFF"
        android:textSize="20dp" />
</LinearLayout>

enter image description here

答案 1 :(得分:0)

要为您的按钮创建圆角,请使用此代码。

<强> round_corner.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
 <item android:state_pressed="true" >
     <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#5e7974" />
         <gradient android:angle="-90" android:startColor="#345953" android:endColor="#689a92"  />            
     </shape>
 </item>
<item android:state_focused="true">
     <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#5e7974" />
         <solid android:color="#58857e"/>       
     </shape>
 </item>  
<item >
    <shape android:shape="rectangle"  >
         <corners android:radius="3dip" />
         <stroke android:width="1dip" android:color="#5e7974" />
         <gradient android:angle="-90" android:startColor="#8dbab3" android:endColor="#58857e" />            
     </shape>
 </item>
</selector>

现在使用它:

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:textColor="#ffffff"
    android:background="@drawable/round_corner"
    android:text="Buttons" />