How to create the Layout like the (Android ICS Contacts Favorite layout )image i attached
am using the grid view for creating the layout for the photos grid. Thats perfectly working. But
how can i create the overlay layout like the black transparent with name or image ?? any one guide me to do this
Thanks in advance
Try this: (Note: this is the Custom XML Layout for the GridView that will be setup in the Adapter)
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center" >
<ImageView
android:id="#+id/imgProfilePicture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/ic_contact_picture" >
</ImageView>
<TextView
android:id="#+id/txtUserName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:background="#50000000"
android:gravity="center"
android:text="User Name"
android:textColor="#ffffff"
android:textSize="11sp" >
</TextView>
</FrameLayout>
And it will look this:
This is as-is from one of my apps. Play around with the android:layout_width and the android:layout_height to set your own size. Also, fiddle with this android:background="#50000000" attribute to get it looking as you please. The 50 in it is the alpha that will set the transparency.
Related
I am trying to create a chat bubble with some text.For this I am create Three Layoutouts,Inside of main Linear Layout I am using FramLayout,I am setting a 9-patch background To this Framlayout.Inside of Framlayout I am adding one more RelativeLayout where I am placing my three textViews and one imageView.but type long text it goes outside of FramLayout border.I don't know what I am doing wrong or what I am missing.When I am using small text it remain fit but with big text it goes out from even Background Border of FramLayout.In attachment I am showing my bubble and yahoo IM bubble.I am trying to create same like yahoo but with some different style.Please give me your suggestion.I try a lot with different ways but not get success.Thanks in advance . .
Here I am placing my Layoutfile
<?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="wrap_content"
android:orientation="horizontal"
android:id="#+id/linearListLayout1">
<FrameLayout
android:id="#+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bubbleblue" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="100dp">
<TextView
android:id="#+id/chattitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"/>
<TextView android:id="#+id/chatdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"/>
<TextView android:id="#+id/chatText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/chatstatus"
android:layout_below="#+id/chattitle"
android:layout_toLeftOf="#+id/chatstatus"
android:text="TextView" />
<ImageView
android:id="#+id/chatstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/add_picture"
android:layout_alignParentRight="true"
android:layout_below="#+id/chatdate"
android:minHeight="2dip"
android:maxWidth="2sp"
android:maxHeight="2sp"
android:layout_marginRight="2dp"/>
</RelativeLayout>
</FrameLayout>
When creating your .9patch image, you also must specify a content area, which you define with the left, and bottom pixels. Check out this.
Use
and
for background of your root layout item.
right click on images and select Save target as.
I try to put a regular button inside an image in android XML. How can it be done? I tried something like this:
<ImageView .......
<Button .... />
</ImageView>
where the dots represent code. Apparently this is not the way because the platform threw an exception.
Can anyone help?
Use relative layout to insert button on the image.
your image should be given in background tag of RelativeLayout.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/list_nav"
>
<Button
android:layout_width="63dp"
android:layout_height="36dp"
android:id="#+id/mapbutton"
android:layout_marginTop="7dp"
android:layout_marginLeft="4dp"
android:layout_alignParentLeft="true"
/>
this Example adds button on left side of the image since i used layout_alignParentLeft="true"
You can use FrameLayout:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView android:id="#+id/myImage"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:src="#drawable/icon" />
<Button android:id="#+id/myButton"
android:layout_width="150dip"
android:layout_height="150dip"
android:text="My Button"/>
</FrameLayout>
You don't write why you need image and button. Do you know about ImageButton?
#Uriel Frankel you may try creating a custom ImageView either.Here is a post regarding Creating Custom ImageView.
Hope it helps.
Hello i am using following xml to create some sort of Transparent panel . The problem i am facing is that the background image ac zoom up , i mean its height get increase , the other thing i would like to know how can i bring this frame in the middle and adjust its width . I have followed this example
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="#drawable/ac" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_gravity="center_horizontal|bottom"
android:padding="12dip"
android:background="#AA000000"
android:textColor="#ffffffff"
android:text="test test test" />
</FrameLayout>
For your ImageView have a look at ScaleType
Try:
android:scaleType="fitXY"
If you want to center your Views have a look at Layout Gravity
I want to make a listview with semi-transparent cells (some sort of blue with 25% opacity).
The listview is created correctly but, when i perform an scroll motion(I press and drag down or up) the list seems to activate some sort of selection mechanism witch applies a black and opaque background to the list.
Any Idea how I can get rid of this?
Below is the code and the two screens:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#drawable/background">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#drawable/my_health_title">
</ImageView>
<ListView android:id="#+id/health" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
<TextView android:id="#+id/health_title" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#46727c"
android:textSize="14sp" android:textStyle="bold"
android:layout_marginTop="20dp" android:layout_marginLeft="30px"
android:text="Blood presure Profile">
</TextView>
<LinearLayout android:id="#+id/health_gauge"
android:layout_width="250dp" android:layout_height="35dp"
android:layout_centerVertical="true" android:layout_marginLeft="20dp">
</LinearLayout>
<TextView android:id="#+id/health_description"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="#46727c" android:textSize="12sp" android:textStyle="normal"
android:layout_marginTop="150px" android:layout_marginLeft="30px"
android:text="Looks Goood">
</TextView>
<ImageView android:id="#+id/health_details"
android:background="#drawable/home_arrow_icon_margin"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_centerVertical="true">
</ImageView>
normal list
selected efect
I was having a nightmare with a similar problem. But I was adding the ListView dynamically, and
android:cacheColorHint="#00000000"
didn't work in this case. The solution:
Don't add ListView dynamically, cacheColorHint will not work
Hope this helps someone!
Just set the android:cacheColorHint to #00000000 on your ListView.
Notice that the color code is an 8 digit code (#AARRGGBB), which means that the first two digits represents the alpha of the color. (If you set it to a 6 digit, #000000 it won't help, because it will be still opaque. For more info on color codes click here).
Your list view should look like this:
<ListView android:id="#+id/health" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000">
</ListView>
More details and explanation can be found here.
I have a header where I have the text: "Huidige Locatie" and beneath that I have an image of a country flag.
I declared the TextView and ImageView in the layout as follows:
<LinearLayout
android:id="#+id/locatiebalk"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="5sp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/vlaggenlocatie"
android:layout_width="105sp"
android:layout_height="fill_parent"
android:paddingLeft="14sp"
android:orientation="vertical">
<TextView
android:id="#+id/huidiglocatie"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Huidige locatie"
android:textColor="#000000"
android:textSize="12sp"/>
<ImageView
android:id="#+id/flag"
android:layout_width="fill_parent"
android:layout_height="46sp"
android:gravity="left"
android:src="#drawable/nl"/>
</LinearLayout>
(I close the tags correctly later on, just showing the relevant part)
In the Graphical Layout of Eclipse it shows it the right way:
But in the Simulator and on my phone it showes it like this:
What is the best way to do this?
Fixed it.
For the ones wondering: android:scaleType="fitStart" did the job.