play audio file in chat with seekbar in android - 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.

Related

ImageView out of dialog bounds

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>

text not aligning properly in scrollview android

i have a scroll view showing certain device information, but it looks like this after setting a DrawableLeft . how do i fix this behaviour? when i remove the drawable, the list looks well formatted. any help will be appreciated
<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"
android:background="#ffffff" >
<!-- action bar -->
<RelativeLayout
android:id="#+id/actionbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:background="#0080FF" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/imageButton1"
android:layout_toRightOf="#+id/imageView5"
android:src="#drawable/ic_font" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:src="#drawable/ic_return" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#00000000"
android:onClick="shareapp"
android:src="#drawable/ic_share" />
</RelativeLayout>
<!-- action bar -->
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/actionbar"
android:background="#drawable/antivirus_bg"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/ipip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="ip"
android:textColor="#084B8A"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/macmac"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="mac"
android:textColor="#084B8A"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/macmac2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="mac2"
android:textColor="#084B8A"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/ssid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="ssid"
android:textColor="#084B8A"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/pubip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="ip2"
android:textColor="#084B8A"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/unique_id_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_device_info"
android:gravity="center"
android:text="extra"
android:textColor="#084B8A"
android:textSize="18sp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
You should use an imageview with specify with and height instead of drawableLeft. Because drawableLeft or drawableRight will get drawable with real with and height of image.
You can remake layout as below:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:src="#drawable/ic_launcher"
/>
<TextView
android:id="#+id/ipip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="ip"
android:layout_marginLeft="16dp"
android:textColor="#084B8A"
android:textSize="18sp" />
</LinearLayout>

Overlaying an imageview relative to another layout

This is what I'm trying to achieve:
I'm trying to add an ImageView (cirlce avatar) which is aligned to the bottom right of the top bar but with an overlay extending below the bar.
Here's what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff652c90">
<ImageButton
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/backBtn"
android:src="#drawable/backarrow"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:id="#+id/infoLayout"
android:layout_centerVertical="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lesky"
android:id="#+id/contactName"
android:textColor="#ffffffff"
android:paddingLeft="10dp"
android:textSize="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="last online 22/4/2016 11:36 am"
android:id="#+id/lastSeen"
android:layout_below="#id/contactName"
android:textColor="#ffd1d2d4"
android:paddingLeft="10dp"
android:textSize="10dp" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:id="#+id/imageView"
android:src="#drawable/contactpiccirlce"
android:scaleType="fitCenter" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/chatView"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#android:color/black"
android:layout_alignBottom="#id/chatView"
android:id="#+id/postArea">
<EditText
android:layout_width="wrap_content"
android:layout_height="30dp"
android:inputType="textMultiLine"
android:minHeight="30dp"
android:ems="10"
android:id="#+id/editText" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
How can anyone achieve this?
Replace with this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#ff652c90" >
<ImageButton
android:id="#+id/backBtn"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:scaleType="fitCenter"
android:src="#drawable/backarrow" />
<RelativeLayout
android:id="#+id/infoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/backBtn" >
<TextView
android:id="#+id/contactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Lesky"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/lastSeen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/contactName"
android:paddingLeft="10dp"
android:text="last online 22/4/2016 11:36 am"
android:textColor="#ffd1d2d4"
android:textSize="10dp" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageView"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="35dp"
android:scaleType="fitCenter"
android:src="#drawable/contactpiccirlce" />
<RelativeLayout
android:id="#+id/secondLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/firstLayout" >
<ListView
android:id="#+id/chatView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:id="#+id/postArea"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignBottom="#id/chatView"
android:background="#android:color/black"
android:orientation="vertical" >
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:ems="10"
android:inputType="textMultiLine"
android:minHeight="30dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
How about this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/infoLayout">
<ImageButton
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/backBtn"
android:src="#drawable/backarrow"
android:background="#android:color/transparent"
android:paddingLeft="10dp"
android:layout_centerVertical="true"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lesky"
android:id="#+id/contactName"
android:textColor="#ffffffff"
android:paddingLeft="10dp"
android:textSize="16dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/backBtn"
android:text="last online 22/4/2016 11:36 am"
android:id="#+id/lastSeen"
android:layout_below="#id/contactName"
android:textColor="#ffd1d2d4"
android:paddingLeft="10dp"
android:textSize="10dp" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#id/infoLayout"
android:layout_alignTop="#id/infoLayout"
android:padding="10dp"
android:scaleType="center"
android:id="#+id/imageView"
android:src="#drawable/contactpiccirlce"
android:scaleType="fitCenter" />

How to make RelativeLayout to scroll when in Portrait orientation mode

I have these 2 images for Land and Portrait mode orientation (Image 1 for Landscape mode, Image 2 for portrait mode, when I write when in Landscape mode and turn the orientation to portrait it does show the full writing i made in Landscape, therefore I want to make it scrollable when the orientation switches to portrait so it can show the full writing i made while it was in Landscape mode.
sorry i don't have up to 10reputations to post the image here directly:-
image 1: http://testimage/1.png
image 2: http://testimage/2.png
Below is the code I use when the orientation is in landscape,FYI: I also created a Layout-Land when in Landsacpe mode
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/color12" >
<LinearLayout
android:id="#+id/menus"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include layout="#layout/menu_layout" />
</LinearLayout>
<RelativeLayout
android:id="#+id/rl_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/menu_layout"
android:layout_below="#+id/menus" >
<FrameLayout
android:id="#+id/layouts"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/iv_note"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</FrameLayout>
<FrameLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" >
<ImageView
android:id="#+id/iv_notes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:visibility="gone" />
</FrameLayout>
<LinearLayout
android:id="#+id/top_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="#+id/lblDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textColor="#222222"
android:textSize="#dimen/title" />
<TextView
android:id="#+id/lblTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="#dimen/title"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/lblTotal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="#222222"
android:textSize="#dimen/title" />
</LinearLayout>
</LinearLayout>
<EditText
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/top_layout"
android:layout_marginBottom="5dp"
android:background="#null"
android:inputType="textMultiLine"
android:textSize="#dimen/title_size" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottom_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/menu_layout"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/attach_view"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:visibility="gone" >
<TextView
android:id="#+id/attachment_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/aImage"
android:ellipsize="start"
android:padding="2dp"
android:singleLine="true"
android:text="Attachment"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#222222" />
<ImageButton
android:id="#+id/aImage"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="3dp"
android:background="#drawable/bottom_bar"
android:padding="10dp"
android:src="#drawable/ic_email_attachment" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bot_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/attach_view"
android:orientation="horizontal" >
<ImageView
android:id="#+id/lblRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:padding="10dp"
android:src="#drawable/tool_left"
android:visibility="gone" />
<ImageView
android:id="#+id/lblLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:padding="10dp"
android:src="#drawable/tool_right"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/menu_layout"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:background="#ffffff"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:orientation="horizontal" >
<include
android:id="#+id/tool_text_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
layout="#layout/tool_text_button_layout"
android:padding="13dp" />
<!--
<ImageView
android:id="#+id/menu_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="#string/content_desc"
android:padding="13dp"
android:src="#drawable/tool_type_text" />
-->
<ImageView
android:id="#+id/menu_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:contentDescription="#string/content_desc"
android:padding="5dp"
android:src="#drawable/tool_thumbs" />
<ImageView
android:id="#+id/menu_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:contentDescription="#string/content_desc"
android:padding="5dp"
android:src="#drawable/sync"
android:visibility="visible" />
<ImageView
android:id="#+id/menu_attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:contentDescription="#string/content_desc"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#drawable/ic_email_attachment_small"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/menu_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:contentDescription="#string/content_desc"
android:paddingBottom="5dp"
android:paddingTop="7dp"
android:src="#drawable/ic_bold"
android:visibility="gone" />
<ImageView
android:id="#+id/menu_italics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:contentDescription="#string/content_desc"
android:paddingBottom="5dp"
android:paddingTop="7dp"
android:src="#drawable/ic_italics"
android:visibility="gone" />
<ImageView
android:id="#+id/menu_underline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:contentDescription="#string/content_desc"
android:paddingBottom="5dp"
android:paddingTop="7dp"
android:src="#drawable/ic_underline"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/list_mode"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/menus"
android:background="#android:color/background_dark"
android:divider="#ffffff"
android:dividerHeight="1dp"
android:visibility="gone" >
</ListView>
<LinearLayout
android:id="#+id/attach_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#android:color/background_light"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<Button
android:id="#+id/Image"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="#drawable/bottom_bar"
android:text="Add Image"
android:textColor="#222222" />
<Button
android:id="#+id/Audio"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="#drawable/bottom_bar"
android:text="Add Audio"
android:textColor="#222222" />
<Button
android:id="#+id/Video"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="#drawable/bottom_bar"
android:text="Add Video"
android:textColor="#222222" />
</LinearLayout>
<ListView
android:id="#+id/mList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal" >
<Button
android:id="#+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="#drawable/bottom_bar"
android:gravity="center"
android:text="Save"
android:textColor="#222222"
android:visibility="gone"
android:width="100dp" />
<Button
android:id="#+id/btncancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:background="#drawable/bottom_bar"
android:gravity="center"
android:text="Exit"
android:textColor="#222222"
android:visibility="visible"
android:width="100dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
This is the selection in the xml that has the yellow writing background
<FrameLayout
android:id="#+id/layouts"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/iv_note"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</FrameLayout>
As far as I know, Relative Layout has no orientation
LINK : http://developer.android.com/reference/android/widget/RelativeLayout.html
However you can make a scrollable view
How to implement HorizontalScrollView like Gallery?

onClick event of fragmentActivity's view inside of Fragment class?

I have included a common layout inside of FragmentActivity.I want to fire onclick event of common layout ToggleButton, inside of fragment class.How can I achieve this?
ToggleButton tbMainLocation = (ToggleButton) getView().findViewById(
R.id.tbMainLocation);
but tbMainLocation always return nullpointerexception
commonlayout:
layout_include.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/rlMainLivTopBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cyan"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView
android:id="#+id/txtMainBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="<"
android:textColor="#color/white"
android:textSize="30sp"
android:visibility="gone" />
<ImageView
android:id="#+id/imgMainBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/back"
android:visibility="gone" />
<AutoCompleteTextView
android:id="#+id/actv_edt_search_tag_feed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="5dp"
android:background="#drawable/round_corner_edittext"
android:ems="10"
android:hint="Search by tag"
android:singleLine="true"
android:text=""
android:textSize="15dp"
android:visibility="gone" >
<requestFocus />
</AutoCompleteTextView>
<TextView
android:id="#+id/txtMainTagneme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text=""
android:textColor="#color/white"
android:visibility="gone" />
<TextView
android:id="#+id/txtMainExpertName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text=""
android:textColor="#color/white"
android:visibility="gone" />
<!--
<ImageView
android:id="#+id/img_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
androImid:background="#drawable/notification" />
-->
<ImageView
android:id="#+id/imgMainExpertEarnByFlight"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="#drawable/plane_normal"
android:visibility="gone" />
<!--
<ImageView
android:id="#+id/imgMainLocation"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/imgMainSearch"
android:background="#drawable/location"
android:visibility="visible" />
-->
<ToggleButton
android:id="#+id/tbMainLocation"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="#drawable/location_selector"
android:focusable="false"
android:focusableInTouchMode="false"
android:textOff=""
android:textOn="" />
</RelativeLayout>
<LinearLayout
android:id="#+id/llExpertfragmentChooseDistance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rl_liv_top_bar"
android:background="#color/light_cyan"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:visibility="gone" >
<TextView
android:id="#+id/txt_choose_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_marginRight="2dp"
android:maxWidth="60dp"
android:paddingLeft="10dp"
android:text="#string/choose_distance"
android:textSize="10dp" />
<ImageView
android:id="#+id/img_expert_earn_by_walk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/walk_normal" />
<TextView
android:id="#+id/txt_cycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_marginLeft="-2dp"
android:layout_marginRight="-2dp"
android:background="#color/cyan_line"
android:maxHeight="6dp"
android:minWidth="40dp" />
<ImageView
android:id="#+id/img_expert_earn_by_cycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cycle_normal" />
<TextView
android:id="#+id/txt_bike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_marginLeft="-2dp"
android:layout_marginRight="-2dp"
android:background="#color/cyan_line"
android:maxHeight="6dp"
android:minWidth="40dp" />
<ImageView
android:id="#+id/img_expert_earn_by_bike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/car_normal" />
<TextView
android:id="#+id/txt_train"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_marginLeft="-2dp"
android:layout_marginRight="-2dp"
android:background="#color/cyan_line"
android:maxHeight="6dp"
android:minWidth="40dp" />
<ImageView
android:id="#+id/img_expert_earn_by_flight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/plane_normal" />
</LinearLayout>
</RelativeLayout>
fragmentactivity.xml
<com.liv.slidingmenu.layout.MainLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- This holds our menu -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll_top_menu_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#6d6d6d"
android:orientation="vertical" >
<!-- This acts as Actionbar -->
<LinearLayout
android:id="#+id/ll_prof_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:background="#434242" >
<RelativeLayout
android:id="#+id/rr_img_detail"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/img_prof"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:background="#drawable/profile_image" />
<TextView
android:id="#+id/txt_expt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img_leve"
android:layout_marginLeft="35dp"
android:layout_marginTop="35dp"
android:layout_toRightOf="#+id/img_prof"
android:text=""
android:textColor="#ffffff" />
<TextView
android:id="#+id/txt_level"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_below="#+id/txt_expt_name"
android:layout_marginLeft="35dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/img_prof"
android:background="#drawable/level_background"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:text=""
android:textColor="#d2d2d2" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_prof_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6" >
<ListView
android:id="#+id/listview_menu_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#292929"
android:dividerHeight="0.1dip" >
</ListView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="#+id/ll_topbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<include
android:id="#+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="#layout/layout_include" />
</RelativeLayout>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/ll_topbar" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="-3dp"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="#+android:id/realtabcontents"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<!-- android:id="#android:id/tabs" -->
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f9f9f9"
android:orientation="horizontal" />
</LinearLayout>
</TabHost>
</RelativeLayout>
</com.liv.slidingmenu.layout.MainLayout>
To access views that belong to the activity layout you can use
getActivity().findViewById(R.id.viewid);
Make sure the fragment is attached to the activity and getActivity() does not return null.
Quoting docs
The fragment can access the Activity instance with getActivity() and
easily perform tasks such as find a view in the activity layout
http://developer.android.com/guide/components/fragments.html

Categories

Resources