Wednesday, 24 October 2012

Top and Bottom Border to textview

package com.example.testscrollview;

import java.util.HashMap;

import java.util.Map;


import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends Activity {
    ImageView image ;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView sample = (TextView) findViewById(R.id.textView1);
        sample.setText("hello test"); 

    }   
}

activity_main.xml






<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:text="TextView"
            android:paddingTop="25dp"
            android:background="@drawable/textlines"
           />
      
    </LinearLayout>

</ScrollView>

Place the following in the drawable folder

textlines.xml

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

    <item>

        <shape android:shape="rectangle" >

            <stroke
                android:width="1dp"
                android:color="#65000B" />

            <solid android:color="#ff215f8b" />
        </shape>
    </item>

    <item
        android:bottom="1dp"
        android:top="1dp">

        <shape android:shape="rectangle" >

            <stroke
                android:width="1dp"
                android:color="#65000B" />

            <solid android:color="#ff215f8b" />
        </shape>
    </item>

</layer-list>

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

    <item>

        <shape android:shape="rectangle" >

            <stroke
                android:width="1dp"
                android:color="#65000B" />

            <solid android:color="#ff215f8b" />
        </shape>
    </item>

    <item
        android:bottom="1dp"
        android:top="1dp">

        <shape android:shape="rectangle" >

            <stroke
                android:width="1dp"
                android:color="#65000B" />

            <solid android:color="#ff215f8b" />
        </shape>
    </item>

</layer-list>

No comments:

Post a Comment

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...