Skip to content Skip to sidebar Skip to footer

How To Put A Horizontal Divisor Line Between Edit Text's In A Activity

I'm making an activity to configure my app, and I have to divide the sections of my configuration window with a line. I used this: divider_horizontal_bright, from this example: htt

Solution 1:

Try this link.... horizontal rule

That should do the trick.

The code below is xml.

<Viewandroid:layout_width="fill_parent"android:layout_height="2dip"android:background="#FF00FF00" />

Solution 2:

If this didn't work:

<ImageViewandroid:layout_gravity="center_horizontal"android:paddingTop="10px"android:paddingBottom="5px"android:layout_height="wrap_content"android:layout_width="fill_parent"android:src="@android:drawable/divider_horizontal_bright" />

Try this raw View:

<Viewandroid:layout_width="fill_parent"android:layout_height="1dip"android:background="#000000" />

Solution 3:

For only one line, you need

...
<View android:id="@+id/primerdivisor"android:layout_height="2dp"android:layout_width="fill_parent"android:background="#ffffff" /> 
...

Solution 4:

How about defining your own view? I have used the class below, using a LinearLayout around a view whose background color is set. This allows me to pre-define layout parameters for it. If you don't need that just extend View and set the background color instead.

publicclassHorizontalRulerViewextendsLinearLayout {

    staticfinalintCOLOR= Color.DKGRAY;
    staticfinalintHEIGHT=2;
    staticfinalintVERTICAL_MARGIN=10;
    staticfinalintHORIZONTAL_MARGIN=5;
    staticfinalintTOP_MARGIN= VERTICAL_MARGIN;
    staticfinalintBOTTOM_MARGIN= VERTICAL_MARGIN;
    staticfinalintLEFT_MARGIN= HORIZONTAL_MARGIN;
    staticfinalintRIGHT_MARGIN= HORIZONTAL_MARGIN;

    publicHorizontalRulerView(Context context) {
        this(context, null);
    }

    publicHorizontalRulerView(Context context, AttributeSet attrs) {
        this(context, attrs, android.R.attr.textViewStyle);
    }

    publicHorizontalRulerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setOrientation(VERTICAL);
        Viewv=newView(context);
        v.setBackgroundColor(COLOR);
        LayoutParamslp=newLayoutParams(
            LayoutParams.MATCH_PARENT,
            HEIGHT
        );
        lp.topMargin = TOP_MARGIN;
        lp.bottomMargin = BOTTOM_MARGIN;
        lp.leftMargin = LEFT_MARGIN;
        lp.rightMargin = RIGHT_MARGIN;
        addView(v, lp);
    }

}

Use it programmatically or in Eclipse (Custom & Library Views -- just pull it into your layout).

Solution 5:

Use This..... You will love it

 <TextView
    android:layout_width="fill_parent"
    android:layout_height="1px"
    android:text=" "
    android:background="#anycolor"
    android:id="@+id/textView"/>

Post a Comment for "How To Put A Horizontal Divisor Line Between Edit Text's In A Activity"