How to achieve this UI in Android?

Prem

In one of my applications, i need to create a border for a linear layout which would look like below

enter image description here

I do not want to have an image and set it as background. Because then i would need to create images of various size for different devices.

If i create the layout with a linear layout and place a textview using absolute positioning, it might not look as expected in different devices.

So What is the best way to achieve this UI ?

appukrb

Try this

main_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_margin="10dp"
            android:background="@drawable/Layout_selector"
            android:orientation="vertical" >
        </LinearLayout>

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="MyText"
            android:layout_marginLeft="50dp"
            android:padding="1dp"
            android:background="#fff"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </FrameLayout>

</LinearLayout>

In Drawable Layout_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_enabled="true"
            android:state_pressed="true">
        <shape android:padding="5dp" android:shape="rectangle">
            <solid android:color="#FFF" />
            <stroke android:width="0.5dp" android:color="#29166f" />
            <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" />
        </shape>
    </item>
    <item android:state_enabled="true" android:state_focused="true">
        <shape android:padding="5dp" android:shape="rectangle">
            <solid android:color="#FFF" />
            <stroke android:width="0.5dp" android:color="#29166f" />
            <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" />
        </shape>
    </item>
    <item android:state_enabled="true">
        <shape android:padding="5dp"
            android:shape="rectangle">
            <solid android:color="#FFF" /> 
            <stroke android:width="0.5dp" android:color="#29166f" />
            <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" />
        </shape>
    </item>

</selector>

Output is :

Output

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to achieve the following in Realm for android

From Dev

How to achieve the smoother indeterminate progressbar used in Gmail's Android app

From Dev

how to achieve optimal display of homepage in Android concerning outfit?

From Dev

How do I achieve a simple TableLayout in Android?

From Dev

How to achieve the same as build.gradle in Eclipse(with Android Developer Tools)

From Dev

How to achieve ellipsize(Three dots) in List item of Android List Item

From Dev

How to achieve smooth UI updates every 16 ms?

From Dev

How to achieve that "ui-sref" be conditionally executed?

From Dev

How to achieve google plus login functionality on own button in Android

From Dev

How to achieve word boundary in Sqlite Android?

From Dev

How to achieve this layout in Android?

From Dev

How does Uber achieve this UI in WatchKit?

From Dev

How to achieve smooth fragment transaction animations on Android

From Dev

How can I achieve this tab style in android?

From Dev

Android - How can I achieve this type of toolbar?

From Dev

android- handler.postDelayed how does it achieve the Delay

From Dev

How to achieve Android Button Animation with text-blurred and shadow

From Dev

How to achieve the smoother indeterminate progressbar used in Gmail's Android app

From Dev

How to achieve edge-depth effect on Android

From Dev

Android How to achieve two screens,two activities,and they are independent

From Dev

Name of the UI used in the App present in playstore and how to achieve the same?

From Dev

How do we achieve this Material Design UI?

From Dev

How to achieve this navigation menu in android

From Dev

How can I achieve this tab style in android?

From Dev

Android - How can I achieve this type of toolbar?

From Dev

How to achieve Android ScreenSaver via service or application

From Dev

How can we achieve this view in android?

From Dev

How to achieve this UI/UX design for an iOS UIButton object

From Dev

How to achieve an "overflowing" riplle-effect in android

Related Related

  1. 1

    How to achieve the following in Realm for android

  2. 2

    How to achieve the smoother indeterminate progressbar used in Gmail's Android app

  3. 3

    how to achieve optimal display of homepage in Android concerning outfit?

  4. 4

    How do I achieve a simple TableLayout in Android?

  5. 5

    How to achieve the same as build.gradle in Eclipse(with Android Developer Tools)

  6. 6

    How to achieve ellipsize(Three dots) in List item of Android List Item

  7. 7

    How to achieve smooth UI updates every 16 ms?

  8. 8

    How to achieve that "ui-sref" be conditionally executed?

  9. 9

    How to achieve google plus login functionality on own button in Android

  10. 10

    How to achieve word boundary in Sqlite Android?

  11. 11

    How to achieve this layout in Android?

  12. 12

    How does Uber achieve this UI in WatchKit?

  13. 13

    How to achieve smooth fragment transaction animations on Android

  14. 14

    How can I achieve this tab style in android?

  15. 15

    Android - How can I achieve this type of toolbar?

  16. 16

    android- handler.postDelayed how does it achieve the Delay

  17. 17

    How to achieve Android Button Animation with text-blurred and shadow

  18. 18

    How to achieve the smoother indeterminate progressbar used in Gmail's Android app

  19. 19

    How to achieve edge-depth effect on Android

  20. 20

    Android How to achieve two screens,two activities,and they are independent

  21. 21

    Name of the UI used in the App present in playstore and how to achieve the same?

  22. 22

    How do we achieve this Material Design UI?

  23. 23

    How to achieve this navigation menu in android

  24. 24

    How can I achieve this tab style in android?

  25. 25

    Android - How can I achieve this type of toolbar?

  26. 26

    How to achieve Android ScreenSaver via service or application

  27. 27

    How can we achieve this view in android?

  28. 28

    How to achieve this UI/UX design for an iOS UIButton object

  29. 29

    How to achieve an "overflowing" riplle-effect in android

HotTag

Archive