text not aligning properly in scrollview android - 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>

Related

scrollview covers up image view

I am trying to make a layout in which there are two main layouts.
One is an imageview and the second one is a scrollview. What I want is that the imageview is always kept on top of the scrollview. When I run the program the image goes back to the scrollview.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/img_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="left|top"
android:layout_margin="10dp"
android:background="#android:color/black"
android:contentDescription="#null"
android:src="#drawable/back" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- Top linear layout -->
<LinearLayout
android:id="#+id/ll_above_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="250dp" >
<com.shotwell.customviews.SmartViewPager
android:id="#+id/vp_slider"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/dots"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" />
<!--
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#null"
android:scaleType="centerCrop"
android:src="#drawable/bigimage" /
-->
>
<TextView
android:id="#+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="Pan-Asian"
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="normal" />
<TextView
android:id="#+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/tv_subtitle"
android:layout_alignLeft="#id/tv_subtitle"
android:text="Oka"
android:textColor="#android:color/white"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/tv_subtitle"
android:layout_marginLeft="16dp"
android:layout_toRightOf="#+id/tv_subtitle"
android:background="#drawable/open_btn"
android:focusable="false"
android:gravity="center"
android:text="Open"
android:textColor="#android:color/white" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#878787" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="56"
android:textColor="#android:color/black"
android:visibility="gone" />
<RatingBar
android:id="#+id/rb_rating"
style="#style/StarRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:rating="5.0" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_desc_toggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Description"
android:textColor="#6A6A6A"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dummy_list_text"
android:textColor="#color/dark_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/rl_map_holder"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="10dp" >
<com.google.android.gms.maps.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/tv_full_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="FullScreen"
android:textColor="#android:color/black"
android:textStyle="bold" />
</RelativeLayout>
<!-- bottom layout -->
<LinearLayout
android:id="#+id/ll_below_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_address_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:text="Berlin Top, Fiapre Suryani"
android:textColor="#android:color/black"
android:textSize="12sp" />
<TextView
android:id="#+id/tv_state_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:text="Brong Afoo, Ghana"
android:textColor="#android:color/black"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone no: "
android:textColor="#android:color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 024133556677"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email: "
android:textColor="#android:color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="abc#yahoo.com"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="URL: "
android:textColor="#android:color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="www.newstate.com"
android:textColor="#android:color/black"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_container_facility"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_toggle_facilities"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Facilities"
android:textColor="#6A6A6A"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/ll_facilities"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<!--
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dummy_list_text"
android:textColor="#color/dark_gray" />
-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_container_hours"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_toggle_timing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hours"
android:textColor="#6A6A6A"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/ll_timings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="0dp"
android:background="#android:color/darker_gray" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>
It's the code of activity. which I am using. Resultant screen looks like this.
So in layouts it shows lines where I place my imageview but it won't show up.
I think maybe the scrollview is pushing back the imageview.
So how to put my imageview on top of the scrollview ?

How can I make layout like this with inflated layout?

I inflate layout to listview and here is what I want:
But I always get something like this:
As you see, the button is always align at the bottom of parent. Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >
<ImageView
android:id="#+id/img_icon_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp" />
<TextView
android:id="#+id/txt_title_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_post_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_title_type"
android:layout_marginTop="16dp"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="15sp" />
<TextView
android:id="#+id/txt_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_post_time"
android:layout_toRightOf="#+id/img_icon_type"
android:text="TextView"
android:textSize="15sp" />
<ImageView
android:id="#+id/img_edit_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:onClick="openPostMenu"
android:src="#drawable/btn_memo_menu" />
<TextView
android:id="#+id/txt_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img_icon_type"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="20sp" />
<ImageView
android:id="#+id/img_posted"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_below="#+id/txt_status"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/img_posted"
android:layout_alignRight="#+id/img_posted"
android:layout_below="#+id/img_posted" >
<RelativeLayout
android:id="#+id/btn_confirm_route"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="#f2f2f2" >
<TextView
android:id="#+id/txt_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/現在地からのル一トを確認" />
<ImageView
android:layout_width="20sp"
android:layout_height="20sp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/txt_address"
android:src="#drawable/btn_memo_route_search_pressed" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Please help me to fix this!Thank you!

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.

Can't implements Scrollview in XML

why I can not show the scroll view in my project, when run does not look scrollview in my project, do I put scrollview not quite right? How Scrollview placement should be, so that all items that are in my project can get scrollview This my XML Code
activity.xml
<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:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:text="#string/cast"
android:layout_marginTop="5dp"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ivPosterImage"
android:layout_marginTop="10dp"
android:id="#+id/scrollView1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:textSize="17sp"
android:text="#string/synopsis" />
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_alignTop="#+id/scrollView1"
android:text="#string/cosensus"
android:textSize="17sp" />
</RelativeLayout>
Your scrollview height should not be defined in wrap because you want it to scroll.
Also the linear inside the scroll should be in wrap for its height and have some elements inside.
Suggestion if you don't mind using linears :
<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:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:textSize="18sp" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:layout_marginTop="5dp"
android:text="#string/cast"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cosensus"
android:textSize="17sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:text="#string/synopsis"
android:textSize="17sp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
<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:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="#+id/scrollView1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/ivPosterImage"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:maxHeight="300dp"
android:src="#drawable/large_movie_poster" />
<TextView
android:id="#+id/tvCriticsScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvTitle"
android:layout_below="#+id/tvTitle"
android:layout_marginTop="5dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/critics_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvCast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvAudienceScore"
android:layout_below="#+id/tvAudienceScore"
android:text="#string/cast"
android:layout_marginTop="5dp"
android:textSize="14sp" />
<TextView
android:id="#+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ivPosterImage"
android:layout_marginLeft="8dp"
android:layout_toRightOf="#+id/ivPosterImage"
android:text="#string/movie_title"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<TextView
android:id="#+id/tvAudienceScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCriticsScore"
android:layout_below="#+id/tvCriticsScore"
android:layout_marginTop="5dp"
android:text="#string/audi_score"
android:textSize="14sp" />
<TextView
android:id="#+id/tvSynopsis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/scrollView1"
android:layout_below="#+id/tvCriticsConsensus"
android:layout_marginTop="48dp"
android:textSize="17sp"
android:text="#string/synopsis" />
<TextView
android:id="#+id/tvCriticsConsensus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cosensus"
android:textSize="17sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

Android scrollview is not scrolling

I have this layout with a scrollview inside:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#eeeeee">
<!-- HEADER -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ffffff"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#868686"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:id="#+id/parent_linear"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/gradient_header" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginBottom="#dimen/margin_normal"
android:layout_marginTop="#dimen/margin_small"
android:gravity="center_horizontal"
android:text="#string/proposed_plan_prompt"
android:textColor="#797A77"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#C7C7C7"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#drawable/gradient_header_separator"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<!-- BODY -->
<!-- Proposed plan (summary) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_normal"
android:layout_marginLeft="#dimen/margin_normal"
android:layout_marginRight="#dimen/margin_normal"
android:background="#drawable/border"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="#dimen/margin_small"
android:layout_marginRight="#dimen/margin_small"
android:orientation="vertical" >
<TextView
android:id="#+id/providerNameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="ABCD"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="#+id/planView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="1234"
android:textSize="12sp"
android:textColor="#737373"/>
</LinearLayout>
<View
android:id="#+id/separator"
android:layout_width="1dip"
android:layout_height="50dp"
android:layout_marginTop="#dimen/margin_small"
android:background="#drawable/gradient_vertical" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentRight="true"
android:layout_marginLeft="#dimen/margin_small"
android:layout_marginRight="#dimen/margin_small"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginLeft="#dimen/margin_small"
android:layout_marginRight="#dimen/margin_small"
android:gravity="top"
android:orientation="horizontal" >
<TextView
android:id="#+id/priceView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="XY"
android:textSize="32sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="+123"
android:textColor="#565756"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/totPriceView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="(information)"
android:textColor="#737373"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_normal"
android:layout_marginLeft="#dimen/margin_normal"
android:layout_marginRight="#dimen/margin_small"
android:layout_marginTop="#dimen/margin_normal"
android:orientation="vertical" >
<TextView
android:id="#+id/detailsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Choose:"
android:textSize="12sp"
android:textStyle="bold" />
<SeekBar
android:id="#+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/detailsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_small"
android:text="Best"
android:textColor="#737373"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/detailsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_normal"
android:text="Details:"
android:textSize="12sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_normal"
android:layout_marginLeft="#dimen/margin_normal"
android:layout_marginRight="#dimen/margin_small"
android:layout_marginTop="#dimen/margin_small"
android:background="#drawable/border"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="90dp"
android:layout_marginRight="#dimen/margin_small"
android:background="#drawable/border"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/line1Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line1Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line1Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line2Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#EAEAEA"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line2Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line2Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line3Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line3Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line3Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line4Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#EAEAEA"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line4Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line4Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line5Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line5Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line5Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/line6Layout"
android:layout_width="match_parent"
android:layout_height="30sp"
android:background="#EAEAEA"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/line6Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal" />
<TextView
android:id="#+id/line6Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/border_attribute"
android:textSize="#dimen/font_normal"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<ImageView
android:id="#+id/imageView1"
android:layout_width="100dp"
android:layout_height="140dp"
android:layout_gravity="left|center_vertical"
android:src="#drawable/robin4" />
</FrameLayout>
<Button
android:id="#+id/button_proposed_extras"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_small"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="#dimen/margin_normal"
android:background="#drawable/button_transparent"
android:text="#string/extras_title"
android:textColor="#298A17"
android:textStyle="bold|italic"
android:visibility="invisible" />
</LinearLayout>
<Button
android:id="#+id/button_proposed_change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_normal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/button"
android:text="#string/proposition_change_title"
android:textColor="#ffffff"
android:textStyle="bold" />
<Button
android:id="#+id/button_proposed_no_change"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_normal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/button_silver"
android:text="#string/proposition_no_change_title"
android:textColor="#298A17"
android:textStyle="bold" />
</LinearLayout>
The part with the scrollview displays at maximum size and is not scrolling.
The two buttons at the end are not displayed, they apparently don't fit in the screen.
I'd like to have the scroll working in order to have buttons appearing.
Why the scrolled layout is displayed at max size instead of being scrolled?
What would be the solution?
For making the buttons to appear in the screen you should have the buttons within the scroll too. Mostly, the screens that you design should have scrollview as the parent if the screen contains many components. Main ScrollView -> LinearLayout / RelativeLayout -> Add Components as needed. By doing so you should have be able to see the buttons also. In doing this way even if your layout changes to landscape the components wont get hidden and will be shown in the scroll. Hope you get my point and it helps you in solving your issue.
As far as the code above is concerned you will not be able to see the buttons as buttons are not within scrollview and hence the view below is hidden.
If doesn't scroll because its height is wrap_content.
As ChristopheCVB stated, your ScrollView needs to NOT be wrap_content. A ScrollView will only scroll if the content it contains is larger (read taller for a vertical ScrollView and wider for a horizontal ScrollView) that the ScrollView itself. If it is smaller, then it has no need to scroll.

Categories

Resources