0

I want to create custom view as below.

---------- OR ---------

Line + 'Phrase' + Line

Which is a correct way to do it? Relative layout, Grid, or what? please advise

3
  • what is "OR"? what is "Line"? Commented Dec 3, 2015 at 13:14
  • 1
    duplicate Commented Dec 3, 2015 at 13:14
  • @noev, on dublicate answer is using relativelayout. But our friend Chirag Savsani is using LinearLayout. Which is a correct answer.Both answers works correctly Commented Dec 3, 2015 at 13:23

1 Answer 1

1

Use this for view.

This will adjust according to your screen width.

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:gravity="center"
            android:orientation="horizontal" >

            <View
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_weight="3"
                android:background="#D0D0D0" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:gravity="center"
                android:layout_weight="1"
                android:singleLine="true"
                android:text="Your text goes here" />

            <View
                android:layout_width="0dp"
                android:layout_height="1dp"
                android:layout_weight="3"
                android:background="#D0D0D0" />
        </LinearLayout>
Sign up to request clarification or add additional context in comments.

1 Comment

noew said it is dublicate. yes it is really dublicate. Sorry for it. But in dublicate question answer is relative layout but in yours one linearLayput. Which to use? Please advise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.