ImageView out of dialog bounds - android

I tried do something like this:
And problem is with icon that go out from dialog bounds.Im understood that I can make one RelativeLayout for all screen,and inner for this dialog,in bigger I must put my icon and try to make them in the head of dialog.Correct?
I tried this but what I have is my icon was like a background of dialog,not at dialog.Like this:
what can I do to change that?
my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rlimageforimage"
android:layout_centerHorizontal="true"
>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/dialog_icon"
android:src="#drawable/emilypic"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/outsideCimage"
android:src="#drawable/cicon"
android:layout_alignTop="#id/dialog_icon"
android:layout_alignBottom="#id/dialog_icon"
android:layout_alignLeft="#id/dialog_icon"
android:layout_alignRight="#id/dialog_icon"
android:scaleType="fitXY"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rounded_corners"
android:layout_marginTop="70dp"
>
<Button
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#drawable/ic_clear_black_18dp"
android:id="#+id/close_button"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/LLTitleandNick"
android:layout_below="#id/rlimageforimage"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dialog_title"
android:textSize="22sp"
android:textColor="#color/title_color"
android:text="Lily Martinson"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/dialog_nickname"
android:textSize="18sp"
android:text="lilmartini"
android:layout_marginLeft="35dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#id/LLTitleandNick"
android:layout_marginTop="40dp"
android:layout_marginLeft="26dp"
android:id="#+id/LLFollowers"
>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image_like"
android:layout_marginLeft="30dp"
android:src="#drawable/ic_favorite_border_black_18dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/Followers"
android:text="Followers"
/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/image_follow"
android:layout_marginLeft="45dp"
android:src="#drawable/ic_directions_walk_black_18dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Following"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_below="#id/LLFollowers"
android:layout_marginTop="50dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/LLwithButtons"
android:layout_below="#+id/LLFollowers"
android:layout_marginTop="70dp"
>
<Button
android:layout_width="55dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:background="#drawable/ic_question_answer_black_18dp"
android:layout_marginLeft="20dp"
/>
<Button
android:layout_width="55dp"
android:layout_height="50dp"
android:background="#drawable/cicon"
android:layout_centerInParent="true"
/>
<Button
android:layout_width="55dp"
android:layout_height="50dp"
android:background="#drawable/ic_person_add_black_18dp"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>

Related

play audio file in chat with seekbar in android

Hi I am new to android and I want to play audio in a list-view. My xml file is like this. How can play audio and update seek bar?
While I am playing the audio file in list then only the last seek bar is moving.
Similar like whatsapp chat app.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll_chat_item_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/rl_main_chat_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#drawable/chat_bg_green"
android:orientation="vertical"
android:padding="5dp"
android:visibility="visible" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" >
<RelativeLayout
android:id="#+id/rl_image_part"
android:layout_width="75dp"
android:layout_height="75dp" >
<ProgressBar
android:id="#+id/pb_loading"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="#+id/iv_message_image"
android:layout_width="75dp"
android:layout_height="75dp"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/temp_picture" />
</RelativeLayout>
<TextView
android:id="#+id/tv_message_chat_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="3dp"
android:text="sample text message"
android:textColor="#color/white" />
<!-- For Adio -->
<RelativeLayout
android:id="#+id/rl_audio_part"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:background="#drawable/playbutton_bg"
android:onClick="playAudio" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="3dp"
android:layout_toRightOf="#+id/play"
android:focusable="false" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:id="#+id/iv_message_devider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/white" />
<TextView
android:id="#+id/tv_send_time_chat_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#color/white" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom|right"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" >
<TextView
android:id="#+id/tv_user_sender_name_chat_item"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#color/white" />
</LinearLayout>
<ImageView
android:id="#+id/iv_mesage_send_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="#drawable/button_edit"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/rl_main_chat_item_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#drawable/chat_bg_white"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="#+id/tv_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_display_name"
android:layout_marginBottom="5dp" >
<RelativeLayout
android:id="#+id/rl_image_part_f"
android:layout_width="75dp"
android:layout_height="75dp"
android:visibility="gone" >
<ProgressBar
android:id="#+id/pb_loading_f"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ImageView
android:id="#+id/iv_message_image_f"
android:layout_width="75dp"
android:layout_height="75dp"
android:contentDescription="#string/app_name"
android:scaleType="fitXY"
android:src="#drawable/temp_picture" />
</RelativeLayout>
<TextView
android:id="#+id/tv_message_chat_item_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="3dp"
android:text="hi" />
<!-- For Adio -->
<RelativeLayout
android:id="#+id/rl_audio_part_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/play_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:background="#drawable/playbutton_bg"
android:onClick="playFAudio" />
<SeekBar
android:id="#+id/seekBar1_f"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="3dp"
android:layout_toRightOf="#+id/play_f"
android:focusable="false" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/play_f"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:id="#+id/iv_message_devider_f"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/white" />
<TextView
android:id="#+id/tv_send_time_chat_item_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="SDFDSFDSFSDD" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom|right"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_mesage_send_status_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="#drawable/button_edit"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
There is no such listeners so that you can keep calling them but how ever you can go with a timer and keep increment the values and change the seekbar values.

how to set text left of relatvie layout in android

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<RelativeLayout
android:id="#+id/relativelayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="15dp" >
<com.lociiapp.utils.RoundedImageView
android:id="#+id/notificationuserimage"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_alignParentLeft="true"
android:layout_marginBottom="17dp"
android:layout_marginLeft="17dp"
android:layout_marginRight="17dp"
android:layout_marginTop="17dp" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_toRightOf="#+id/notificationuserimage"
android:fontFamily="calibri"
android:paddingRight="20dp"
android:text="Request For Travlling to You"
android:textColor="#888686"
android:textSize="15dp" />
<TextView
android:id="#+id/revresetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/desc"
android:layout_marginRight="32dp"
android:layout_marginTop="1dp"
android:layout_toRightOf="#+id/notificationuserimage"
android:textColor="#c9cdd0"
android:textSize="12dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/linearlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="17dp"
android:layout_marginRight="25dp"
android:layout_marginTop="17dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="8dp"
android:paddingRight="10dp"
android:src="#drawable/rejecticon" />
<View
android:id="#+id/view1"
android:layout_width="1dp"
android:layout_height="50dp"
android:layout_toRightOf="#id/imageView1"
android:background="#e0e0e0" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="#id/view1"
android:paddingLeft="10dp"
android:src="#drawable/accepticon" />
</RelativeLayout>
</RelativeLayout>
This is my xml I am trying to set one Relative-layout always come right of other relative layout when Relative Layout visibility and in single text-view text auto adjust when other Relative Layout invisible. Please help me where I am doing wrong ? please find the attachment. There is Text-view collapse.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:weightSum="1"
android:id="#+id/rl_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<RelativeLayout
android:id="#+id/relativelayout2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:paddingBottom="15dp" >
<com.lociiapp.utils.RoundedImageView
android:id="#+id/notificationuserimage"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_alignParentLeft="true"
android:layout_marginBottom="17dp"
android:layout_marginLeft="17dp"
android:layout_marginRight="17dp"
android:layout_marginTop="17dp" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_toRightOf="#+id/notificationuserimage"
android:fontFamily="calibri"
android:paddingRight="20dp"
android:text="Request For Travlling to You"
android:textColor="#888686"
android:textSize="15dp" />
<TextView
android:id="#+id/revresetime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/desc"
android:layout_marginRight="32dp"
android:layout_marginTop="1dp"
android:layout_toRightOf="#+id/notificationuserimage"
android:textColor="#c9cdd0"
android:textSize="12dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/linearlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="17dp"
android:layout_marginRight="25dp"
android:layout_marginTop="17dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="8dp"
android:paddingRight="10dp"
android:src="#drawable/rejecticon" />
<View
android:id="#+id/view1"
android:layout_width="1dp"
android:layout_height="50dp"
android:layout_toRightOf="#id/imageView1"
android:background="#e0e0e0" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="#id/view1"
android:paddingLeft="10dp"
android:src="#drawable/accepticon" />
</RelativeLayout>
</LinearLayout>

Why the keyboard is overing the Edittext?

I have a layout for ldpi with some elements inside a scrowview.
I have two edittexts and when I click one of then, the keyboard
is overriding the edittext. Its haoening only in this screen and only in
this size of screnn. I have others layouts files with edittexts and It happens
only in this layout.
This is the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".NovoCheckinActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="67dp"
android:layout_weight="0.03"
android:background="#drawable/header"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imgVoltaNovoCheckin"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="7dp"
android:layout_marginTop="13dp"
android:src="#drawable/bt_back"
android:onClick="voltaNovoCheckin"/>
<TextView
android:id="#+id/labelAutenticacaoNovoCheckin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imgVoltaNovoCheckin"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/imgVoltaNovoCheckin"
android:text="Novo Check-in"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/tvEventoClienteNovoCheckin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/imgVoltaNovoCheckin"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/imgVoltaNovoCheckin"
android:text="Reuniao - Porto Seguro"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="8"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="380dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="410dp"
android:focusableInTouchMode="true"
android:layout_weight="1.03" >
<TextView
android:id="#+id/labelTipoCheckin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="24dp"
android:layout_marginTop="5dp"
android:text="Tipo:"
android:textColor="#333333" />
<Button
android:id="#+id/btTipoCheckin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/labelTipoCheckin"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="2dp"
android:background="#drawable/borda_botao"
android:hint="Chegada/Saída/Presença" />
<Button
android:id="#+id/btLocal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/labelLocal"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="2dp"
android:background="#drawable/borda_botao"
android:hint="Empresa/Cliente/Minha Casa" />
<EditText
android:id="#+id/etObservacoesNovoCheckin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/labelObservacoes"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="2dp"
android:background="#drawable/borda_botao"
android:paddingLeft="5dp" >
</EditText>
<TextView
android:id="#+id/labelLocal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/labelTipoCheckin"
android:layout_below="#+id/btTipoCheckin"
android:text="Local:"
android:textColor="#333333" />
<EditText
android:id="#+id/etCustoNovoCheckin"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_below="#+id/labelCustoNovoCheckin"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50dp"
android:background="#drawable/borda_botao"
android:inputType="numberDecimal"
android:paddingLeft="5dp" />
<Button
android:id="#+id/btSalvarNovoCheckin"
android:layout_width="150dp"
android:layout_height="35dp"
android:layout_below="#+id/etCustoNovoCheckin"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_weight="0.03"
android:background="#drawable/bt_green"
android:text="Salvar"
android:textColor="#android:color/white"
android:textSize="20sp" />
<TextView
android:id="#+id/labelObservacoes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/labelLocal"
android:layout_below="#+id/btLocal"
android:layout_marginTop="10dp"
android:text="Observações:"
android:textColor="#333333" />
<TextView
android:id="#+id/labelCustoNovoCheckin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/btCheck"
android:layout_below="#+id/btCheck"
android:layout_marginTop="10dp"
android:text="Custo:"
android:textColor="#333333" />
<ImageView
android:id="#+id/invisible"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignRight="#+id/labelTipoCheckin"
android:layout_alignTop="#+id/btCheck"
android:src="#drawable/invisible" />
<TextView
android:id="#+id/labelCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/invisible"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/labelCustoNovoCheckin"
android:text="Último Check-in do evento?"
android:textSize="13sp" />
<ImageView
android:id="#+id/btCheck"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignRight="#+id/invisible"
android:layout_below="#+id/etObservacoesNovoCheckin"
android:layout_marginTop="10dp"
android:background="#drawable/btunchecked" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
take a look at the activity android:windowSoftInputMode modes to help with your adjustment of items on screen

How to align Buttons under a ListView?

I'm trying to align a number of buttons under a list of items.
It's appearing as follows:
But I need it to appear as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="7dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myImage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="[TextView text]"
android:textSize="20sp"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:id="#+id/lblOverviewText"
android:textStyle="bold"
android:textSize="15sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1" />
<TextView
android:id="#+id/lblEngineer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblOverviewText" />
<TextView
android:id="#+id/lblAlarmEvents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblEngineer" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/lblAlarmEvents" />
<LinearLayout
android:id="#+id/linearLayoutSetUnsetButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/list">
<ImageButton
android:id="#+id/btnFullSet"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Full Set"
android:layout_margin="5dp"
android:src="#drawable/lock_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetA"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part A"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetA_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetB"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part B"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetB_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnUnset"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Unset"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/Unset_128"
android:scaleType="fitCenter"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
Try this way
Make your listview wrap_content
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lblAlarmEvents" />
<LinearLayout
android:id="#+id/linearLayoutSetUnsetButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_below="#+id/list">
XML file will be like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="7dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myImage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="[TextView text]"
android:textSize="20sp"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:id="#+id/lblOverviewText"
android:textStyle="bold"
android:textSize="15sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1" />
<TextView
android:id="#+id/lblEngineer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblOverviewText" />
<TextView
android:id="#+id/lblAlarmEvents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblEngineer" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/lblAlarmEvents" />
<LinearLayout
android:id="#+id/linearLayoutSetUnsetButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/list">
<ImageButton
android:id="#+id/btnFullSet"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Full Set"
android:layout_margin="5dp"
android:src="#drawable/lock_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetA"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part A"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetA_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetB"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part B"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetB_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnUnset"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Unset"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/Unset_128"
android:scaleType="fitCenter"
android:visibility="gone" />
</LinearLayout>
Or If you want your image button's parent layout as a footer set the xml like this:
XML file will be like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="7dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myImage" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="[TextView text]"
android:textSize="20sp"
android:layout_gravity="center" />
</LinearLayout>
<TextView
android:id="#+id/lblOverviewText"
android:textStyle="bold"
android:textSize="15sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1" />
<TextView
android:id="#+id/lblEngineer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblOverviewText" />
<TextView
android:id="#+id/lblAlarmEvents"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/lblEngineer" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/lblAlarmEvents" />
<LinearLayout
android:id="#+id/linearLayoutSetUnsetButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<ImageButton
android:id="#+id/btnFullSet"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Full Set"
android:layout_margin="5dp"
android:src="#drawable/lock_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetA"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part A"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetA_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnPartsetB"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Part B"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/PartSetB_128"
android:scaleType="fitCenter" />
<ImageButton
android:id="#+id/btnUnset"
android:background="#null"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Unset"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:src="#drawable/Unset_128"
android:scaleType="fitCenter"
android:visibility="gone" />
</LinearLayout>

Listview item fits to row

I have a listview with two textviews in a row like name and result. I want to fit the textview to the row because I need to set a background color to the second textview.I have tried "match_parent"fill_parent"..etc
//items.xml
<ImageView
android:id="#+id/imgViewLogo"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txtViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtViewDescription"
android:layout_alignBottom="#+id/txtViewDescription"
android:layout_marginLeft="6dp"
android:layout_toRightOf="#+id/imgViewLogo"
android:text="TextView"
android:textStyle="bold" />
<MyTextView
android:id="#+id/txtViewDescription"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imgViewLogo"
android:layout_marginRight="33dp"
android:layout_gravity="center"
android:text="TextView"
android:textStyle="bold" />
<ImageView
android:id="#+id/temperrr"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/resultarrawnocolor" />
</RelativeLayout>
// listview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/gl1"
style="?android:attr/buttonStyleSmall"
android:layout_width="64dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/back"
android:gravity="center_vertical"
android:onClick="backMan" />
<TextView
android:id="#+id/textVie3"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/gl1"
android:background="#drawable/header_line" />
<Button
android:id="#+id/gl2"
style="?android:attr/buttonStyleSmall"
android:layout_width="64dp"
android:layout_height="40dp"
android:layout_above="#+id/textVie3"
android:layout_alignParentRight="true"
android:background="#drawable/info"
android:gravity="center_vertical"
android:onClick="info" />
<TextView
android:id="#+id/textVie1"
android:layout_width="135dp"
android:layout_height="30dp"
android:layout_alignBaseline="#+id/gl2"
android:layout_alignBottom="#+id/gl2"
android:layout_centerHorizontal="true"
android:background="#drawable/uchek_header"
android:gravity="center" />
<TextView
android:id="#+id/bgnf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textVie3"
android:background="#drawable/main_bag" />
<TextView
android:id="#+id/myTextView1"
android:layout_width="375dp"
android:layout_height="35dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/bgnf1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/textviewtableheader"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="Result"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="#+id/btnemail"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#drawable/email"/>
<Button
android:id="#+id/btnsave"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/save"
/>
<Button
android:id="#+id/btnrec"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/myTextView1"
android:background="#drawable/rec"
/>
<ListView
android:id="#+id/lv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/btnemail"
android:layout_alignLeft="#+id/myTextView1"
android:layout_alignRight="#+id/myTextView1"
android:layout_below="#+id/myTextView1"
android:background="#color/White"
android:divider="#drawable/tabledivider"
android:dividerHeight="1dp"
android:listSelector="#drawable/listcolor"
tools:listitem="#android:layout/simple_list_item_1" >
</ListView>
</RelativeLayout>
If you want the height to be of icon size you can use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:weightSum="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#F00"
android:gravity="center_vertical"
android:text="Envelope" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight=".5"
android:background="#990"
android:gravity="center_vertical"
android:text="1000ml/Dl" />
</LinearLayout>
</LinearLayout>
Try distributing the weight of ImageView , TextView , TextView and ImageView to get the desired result.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imgViewLogo"
android:layout_width="22dip"
android:layout_height="22dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="center"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linear_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/temperrr"
android:layout_toRightOf="#+id/imgViewLogo"
android:orientation="horizontal"
android:weightSum="1.0" >
<TextView
android:id="#+id/txtViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txtViewDescription"
android:layout_alignBottom="#+id/txtViewDescription"
android:layout_toRightOf="#+id/imgViewLogo"
android:layout_weight="0.5"
android:background="#ff0000"
android:text="TextView"
android:textStyle="bold" />
<TextView
android:id="#+id/txtViewDescription"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imgViewLogo"
android:layout_gravity="center"
android:layout_weight="0.5"
android:background="#ffff00"
android:text="TextView"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:id="#+id/temperrr"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
may be this will help, i edited the answer,check now

Categories

Resources