Android UI How to - ImageView and color








You can even specify just a color, and the ImageView will display that color.

Example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
//from  w  w  w  . j a  v  a2 s  .  co  m
    <ImageView
        android:id="@+id/image2"
        android:layout_width="125dip"
        android:layout_height="25dip"
        android:src="#555555" />
</LinearLayout>

Java code

package com.java2s.myapplication3.app;
//from ww  w .jav  a  2 s.co  m
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

}
null