Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change relative layout border color?

Tags:

android

how to change relative layout border color?? this is my code below i just want to show border color black but is show all relative layout black. i just want to show relative layout white color only borde will be black what will i do??

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/border5">

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
     <item> 
         <shape android:shape="rectangle">
              <solid android:color="#000000" /> 
         </shape>
     </item>   
     <item android:left="1dp"  android:top="1dp" android:bottom="2dp" >  
         <shape android:shape="rectangle"> 
         </shape>
      </item>    
</layer-list> 
like image 983
user2589245 Avatar asked Jul 31 '13 20:07

user2589245


People also ask

How do I change the layout border color?

Select the table cells that you want to add a border to (or change the border of). Select the Table Tools / Design tab on the ribbon. Select one of the following in the Draw Borders group: Use Pen Color to change the color of the border.

How do I add a border to relative layout?

Create a FrameLayout that gets the background color of your border, and a margin or padding of your border width, and place that FrameLayout in your RelativeLayout. Place the TextView in your FrameLayout instead of directly in the RelativeLayout. poof instant border. Show activity on this post.

What is the difference between relative layout and frame layout?

RelativeLayout : is a ViewGroup that displays child views in relative positions. AbsoluteLayout : allows us to specify the exact location of the child views and widgets. TableLayout : is a view that groups its child views into rows and columns. FrameLayout : is a placeholder on screen that is used to display a single ...

How do you change the color of the border on Android?

To add a border to Android TextView we need to create an XML containing shape as a rectangle file under the drawable's folder and set it as background to the TextView. <stroke> tag is used to set the border width and color.


1 Answers

This is how I give mine a white background and orange border

    <shape xmlns:android="http://schemas.android.com/apk/res/android"    
    android:shape="rectangle" >

    <solid android:color="@drawable/white" />

    <stroke
        android:width="3px"
        android:color="@drawable/orange" />

   </shape>

If you simply just want a border then you can keep it all in the same <shape> and use <solid...> for the background color (if you want to give it one) and <stroke...> for the border.

You can do it how you have it just change the <solid> to the background color you want and add the <stroke> with black

like image 140
codeMagic Avatar answered Oct 15 '22 19:10

codeMagic