HorizontalScrollView not working - android

I am unable to scroll horizontally using HorizontalScrollView, but the same code in other files appears to work fine. I am unable to find an error in this file.
Here is the HorizontalScrollView xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#87E886"
android:orientation="horizontal">
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="2200dp"
android:layout_height="550dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<!--D2-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView16"
android:src="#drawable/des1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageView17"
android:src="#drawable/img_bahay"
android:layout_below="#+id/imageView16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView18"
android:src="#drawable/des_bahay"
android:layout_below="#+id/imageView17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageView19"
android:layout_below="#+id/imageView18"
android:src="#drawable/desc_bahay"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/xaxaw"
android:src="#drawable/arrow"
></ImageView>
<!--D3-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa16"
android:src="#drawable/des2"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewa17"
android:src="#drawable/img_chinatown"
android:layout_below="#+id/imageViewa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa18"
android:src="#drawable/des_chinatown"
android:layout_below="#+id/imageViewa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewa19"
android:src="#drawable/desc_chinatown"
android:layout_below="#+id/imageViewa18"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" />
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Duration:"
android:id="#+id/textView13"
android:textColor="#000000"
android:layout_below="#+id/imageView19"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView14"
android:textColor="#000000"
android:layout_below="#+id/textView13"
android:layout_alignParentStart="true"
android:layout_marginLeft="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Distance:"
android:id="#+id/textView15"
android:textColor="#000000"
android:layout_alignTop="#+id/textView13"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView16"
android:textColor="#000000"
android:layout_marginLeft="35dp"
android:layout_below="#+id/textView15"
android:layout_alignStart="#+id/textView15"/> -->
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow1"
android:src="#drawable/arrow"
></ImageView>
<!-- D4-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa16"
android:src="#drawable/des3"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaa17"
android:src="#drawable/img_goodwill"
android:layout_below="#+id/imageViewaa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa18"
android:src="#drawable/des_goodwill"
android:layout_below="#+id/imageViewaa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaa19"
android:src="#drawable/desc_goodwill"
android:layout_below="#+id/imageViewaa18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow53"
android:src="#drawable/arrow"
></ImageView>
<!--D5-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag16"
android:src="#drawable/des4"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaag17"
android:src="#drawable/img_chcemetery"
android:layout_below="#+id/imageViewaag16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag18"
android:src="#drawable/des_chcemetery"
android:layout_below="#+id/imageViewaag17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaag19"
android:src="#drawable/desc_chcemetery"
android:layout_below="#+id/imageViewaag18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>

Make HorizontalScrollView's with to "wrap_content" and maintain a single child to the HorizontalScrollView i.e.
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
rest of the code here......
</LinearLayout>
</HorizontalScrollView>

it seems like you have forgotten to end the LinearLayout tag before ending HorizontalScrollView . Your code should look like this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#87E886"
android:orientation="horizontal">
<HorizontalScrollView
android:id="#+id/scrollView1"
android:layout_width="2200dp"
android:layout_height="550dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<!--D2-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView16"
android:src="#drawable/des1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageView17"
android:src="#drawable/img_bahay"
android:layout_below="#+id/imageView16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageView18"
android:src="#drawable/des_bahay"
android:layout_below="#+id/imageView17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageView19"
android:layout_below="#+id/imageView18"
android:src="#drawable/desc_bahay"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/xaxaw"
android:src="#drawable/arrow"
></ImageView>
<!--D3-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa16"
android:src="#drawable/des2"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewa17"
android:src="#drawable/img_chinatown"
android:layout_below="#+id/imageViewa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewa18"
android:src="#drawable/des_chinatown"
android:layout_below="#+id/imageViewa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewa19"
android:src="#drawable/desc_chinatown"
android:layout_below="#+id/imageViewa18"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" />
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Duration:"
android:id="#+id/textView13"
android:textColor="#000000"
android:layout_below="#+id/imageView19"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView14"
android:textColor="#000000"
android:layout_below="#+id/textView13"
android:layout_alignParentStart="true"
android:layout_marginLeft="35dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Estimated Distance:"
android:id="#+id/textView15"
android:textColor="#000000"
android:layout_alignTop="#+id/textView13"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/textView16"
android:textColor="#000000"
android:layout_marginLeft="35dp"
android:layout_below="#+id/textView15"
android:layout_alignStart="#+id/textView15"/> -->
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow1"
android:src="#drawable/arrow"
></ImageView>
<!-- D4-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa16"
android:src="#drawable/des3"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaa17"
android:src="#drawable/img_goodwill"
android:layout_below="#+id/imageViewaa16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaa18"
android:src="#drawable/des_goodwill"
android:layout_below="#+id/imageViewaa17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaa19"
android:src="#drawable/desc_goodwill"
android:layout_below="#+id/imageViewaa18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="180dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="30dp"
android:layout_width="205dp"
android:layout_height="100dp"
android:id="#+id/arrow53"
android:src="#drawable/arrow"
></ImageView>
<!--D5-->
<LinearLayout
android:layout_width="310dp"
android:layout_height="520dp"
android:background="#024500"
android:layout_marginLeft="10dp">
<RelativeLayout
android:layout_width="290dp"
android:layout_height="499dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:background="#BEFFB6"
android:layout_marginLeft="10dp"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag16"
android:src="#drawable/des4"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp" />
<ImageView
android:layout_width="220dp"
android:layout_height="190dp"
android:id="#+id/imageViewaag17"
android:src="#drawable/img_chcemetery"
android:layout_below="#+id/imageViewaag16"
android:layout_alignParentStart="true"
android:layout_marginLeft="35sp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="#+id/imageViewaag18"
android:src="#drawable/des_chcemetery"
android:layout_below="#+id/imageViewaag17"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="120dp"
android:id="#+id/imageViewaag19"
android:src="#drawable/desc_chcemetery"
android:layout_below="#+id/imageViewaag18"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>

ScrollView or in your case HorizontalScrollView can only have one direct child view. Like :
<ScrollView>
<LinearLayout>
// add all the required views here.
</Linearlayout>
</Scrollview>
Although, you can add mulitiple views inside that Linear or any other layout.

Related

How to draw a line over current screen?

i have a linear layout which is linked to an activity and i want to draw a line over it from a view class using addview but the problem is that when i add using addview then it shift the whole screen upwards. I want to draw a line at specific position without changing the layout. if this can we done by any other method that will be ok. Please help. Also tell that how to remove a Addview.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:weightSum="7"
android:background="#mipmap/untitled_3"
android:id="#+id/multiplayer_game_activity"
tools:context="com.bussiness.vidit.ticktacknoughtsandcrosses.Multiplayer_game">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_weight="1.18"
android:weightSum="3">
<TextView
android:id="#+id/reset_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/name_tv"
android:layout_alignBottom="#+id/name_tv"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:onClick="reset"
android:text="RESET"
android:textColor="#android:color/holo_blue_bright"
android:textSize="10sp" />
<TextView
android:id="#+id/name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textColor="#android:color/white"
android:textSize="18sp"
android:layout_alignBaseline="#+id/turn_tv"
android:layout_alignBottom="#+id/turn_tv"
android:layout_toRightOf="#+id/turn_tv"
android:layout_toEndOf="#+id/turn_tv" />
<TextView
android:id="#+id/turn_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_marginStart="9dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:text="TURN - "
android:textColor="#android:color/holo_purple"
android:textSize="15sp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.87">
<ImageView
android:id="#+id/iv1"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv2"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv3"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.68">
<ImageView
android:id="#+id/iv4"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv5"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv6"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:weightSum="3"
android:layout_weight="0.80">
<ImageView
android:id="#+id/iv7"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv8"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/iv9"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_weight="4">
<com.google.android.gms.ads.AdView
android:id="#+id/adView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_home_footer"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"></com.google.android.gms.ads.AdView>
<ImageView
android:id="#+id/imageView4"
android:layout_width="75dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:src="#drawable/cross" />
<TextView
android:id="#+id/cross_win_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView4"
android:layout_alignStart="#+id/imageView4"
android:layout_below="#+id/imageView4"
android:layout_marginLeft="29dp"
android:layout_marginStart="29dp"
android:text="0"
android:textColor="#android:color/holo_green_light"
android:textSize="25dp" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="75dp"
android:layout_height="50dp"
android:layout_above="#+id/cross_win_tv"
android:layout_centerHorizontal="true"
android:layout_weight="1"
android:src="#drawable/circle" />
<TextView
android:id="#+id/cirle_win_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView5"
android:layout_centerHorizontal="true"
android:text="0"
android:textColor="#android:color/holo_red_light"
android:textSize="25dp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/imageView4"
android:layout_marginEnd="11dp"
android:layout_marginRight="11dp"
android:text="Draws"
android:textColor="#android:color/holo_orange_light"
android:textSize="25dp" />
<TextView
android:id="#+id/draw_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView4"
android:layout_alignStart="#+id/textView4"
android:layout_below="#+id/imageView5"
android:layout_marginLeft="27dp"
android:layout_marginStart="27dp"
android:text="0"
android:textColor="#android:color/holo_orange_light"
android:textSize="25dp" />
</RelativeLayout>
I couldn't get exactly what you want. I assume that you want to draw a "1 px line". If so, you can do it like this:
<View
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="1dp" />

Can´t add elements to HorizontalScrollView programatically

I'm inserting TextView elements dynamically, but only the last ones are inserted and the first ones are missing.
XML of HorizontalScrollView:
<HorizontalScrollView
android:id="#+id/mainScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="45dp"
android:layout_marginRight="45dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/scrollLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
Full XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backround">
<RelativeLayout
android:id="#+id/article"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/linearLayout3"
android:layout_marginBottom="15dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="15dp"
android:background="#drawable/edittext">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/textView35"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<HorizontalScrollView
android:id="#+id/mainScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="45dp"
android:layout_marginRight="45dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/scrollLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView46"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginLeft="17dp"
android:layout_toEndOf="#+id/imageView45"
android:layout_toRightOf="#+id/imageView45"
app:srcCompat="#mipmap/likeicon" />
<ImageView
android:id="#+id/imageView45"
android:layout_width="125dp"
android:layout_height="45dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/pujar" />
<ImageView
android:id="#+id/imageView47"
android:layout_width="wrap_content"
android:layout_height="27dp"
android:layout_alignTop="#+id/imageView46"
android:layout_marginRight="13dp"
android:layout_toLeftOf="#+id/imageView45"
android:layout_toStartOf="#+id/imageView45"
app:srcCompat="#mipmap/deleteicon" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/relativeLayout5"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toEndOf="#+id/imageView44"
android:layout_toRightOf="#+id/imageView44"
android:text="Article title"
android:textSize="15sp" />
<ImageView
android:id="#+id/imageView44"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
app:srcCompat="#mipmap/unknown" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/mainContentImage"
android:layout_width="match_parent"
android:layout_height="255dp"
android:layout_below="#+id/relativeLayout5"
android:background="#mipmap/surf">
</RelativeLayout>
<TextView
android:id="#+id/textView35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/mainContentImage"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="Puja actual:"
android:textColor="#color/bidsy"
android:textSize="15sp" />
<TextView
android:id="#+id/textView36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView35"
android:layout_alignBottom="#+id/textView35"
android:layout_marginLeft="3dp"
android:layout_toEndOf="#+id/textView35"
android:layout_toRightOf="#+id/textView35"
android:text="120"
android:textColor="#color/bidsy"
android:textSize="16sp" />
<TextView
android:id="#+id/textView37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView35"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:text="1 Dia 4 horas"
android:textColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#color/bidsy"
android:visibility="gone">
<ImageView
android:id="#+id/imageView15"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="searchClick"
android:padding="12dp"
app:srcCompat="#mipmap/search" />
<ImageView
android:id="#+id/imageView144"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:clickable="true"
android:onClick="menuClick"
android:padding="10dp"
app:srcCompat="#mipmap/menu" />
<ImageView
android:id="#+id/imageViewBar"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#mipmap/title" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutSearchBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayoutBar"
android:background="#color/bidsy">
<EditText
android:id="#+id/editText13"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="125dp"
android:background="#drawable/edittextsearch"
android:ems="10"
android:gravity="center"
android:hint="Busca en Bidsy!"
android:inputType="textPersonName"
android:textColor="#color/white"
android:textColorHint="#E95355" />
<ImageView
android:id="#+id/imageView155"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="12dp"
app:srcCompat="#mipmap/search" />
<ImageView
android:id="#+id/imageView14"
android:layout_width="45dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:clickable="true"
android:onClick="menuClick"
android:padding="10dp"
app:srcCompat="#mipmap/menu" />
</RelativeLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayoutSearchBar"
android:background="#color/white"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/tab1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar1"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4354"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar2"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4351"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar3"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView4356"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar4"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView43523"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar5"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView435233"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab6"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar6"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView435"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/tab7"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="tabClick">
<RelativeLayout
android:id="#+id/bar7"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:background="#color/bidsy">
</RelativeLayout>
<ImageView
android:id="#+id/imageView43"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:srcCompat="#mipmap/bidsytab" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Code to load elements:
private void loadScrollElements() {
LinearLayout yourLayout = (LinearLayout) findViewById(R.id.scrollLayout);
for (int i = 1; i < 25; i++) {
TextView tv = new TextView(this);
tv.setText(i + "");
tv.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv.setTextSize(20);
yourLayout.addView(tv);
}
}
I see in mainScroll items from 11 to 24 + empty space.
Curiously that blank space seems to be the space that would take the missing elements at the beginning.
Why I don´t see 1..10 items?
The android:layout_gravity="center" of the LinearLayout causes the problem. When you change it to android:layout_gravity="center_vertical", all the TextView's will be visible again.
I'm not sure, but I guess that because the TextView's are added programmatically the LinearLayout miscalculates it's horizontal center.
Please correct me if I'm wrong.

android: Image disappears while translation animation

I'm trying to rotate the image as shown in the following bead images clockwise. But the problem is pretty much evident from the pictures i.e. the bead is getting disappeared.
-> -> -> ->
Following is my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical" >
<!-- *******************************top 1 beads ************************** -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:background="#null"
android:layout_centerHorizontal="true" >
<!--
<ImageView
android:id="#+id/tasbih_thread"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="-5dp"
android:src="#drawable/tasbih_thread" />
-->
<ImageView
android:id="#+id/bead1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="81dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="65dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="2dp"
android:layout_marginTop="3dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="78dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="164dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="98dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="3dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="184dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="120dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="3dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="148dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="208dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="176dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="212dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="203dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
<RelativeLayout
android:id="#+id/allah_number_relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/tasbih_counter_star"
android:gravity="center" >
<TextView
android:id="#+id/allah_number_textview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/green"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="210dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="228dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<!-- *******************************top 8 beads ************************** -->
<RelativeLayout
android:id="#+id/tableRow2"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="253dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="2dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="280dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="194dp"
android:layout_height="wrap_content"
android:background="#null"
android:layout_centerHorizontal="true"
android:layout_marginTop="305dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="184dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="#null"
android:layout_marginTop="330dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="164dp"
android:layout_height="wrap_content"
android:background="#null"
android:layout_centerHorizontal="true"
android:layout_marginTop="355dp"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="0dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="375dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="6dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="390dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="4dp"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="6dp"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
<RelativeLayout
android:layout_width="53dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="402dp"
android:background="#null"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/bead18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#drawable/tasbih_bead_desl" />
<ImageView
android:id="#+id/bead17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/tasbih_bead_desl" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Following is the translation function:
#Override
public void onWindowFocusChanged (boolean hasFocus){
super.onWindowFocusChanged(hasFocus);
if(hasFocus){
int[] arr=new int[2];
for(int i=0;i<33;i++)
{
((ImageView)findViewById(image_drawable[i])).getLocationOnScreen(arr);
xArrayList.add(arr[0]);
yArrayList.add(arr[1]);
Log.e("x= "+((ImageView)findViewById(image_drawable[i])).getRight(),"y= "+((ImageView)findViewById(image_drawable[i])).getBottom());
}
}
}
and following is the function to get the co-ordinates which is called onTouch of the screen:
private void startTranslateAnimation()
{
for(int i=0;i<=32;i++)
{
int x1=xArrayList.get(i);
int y1=yArrayList.get(i);
int x2,y2;
if(i<=31)
{
x2=xArrayList.get(i+1);
y2=yArrayList.get(i+1);
}
else
{
x2=xArrayList.get(0);
y2=yArrayList.get(0);
}
TranslateAnimation left_animation = new TranslateAnimation(0,x2-x1,0,y2-y1);
left_animation.setDuration(2000);
left_animation.setFillAfter(false);
findViewById(image_drawable[i]).startAnimation(left_animation);
}
}
any help?

hot to make a textView in a layout only scrollalbe not the whole layout?

I have several layouts in my xml layout in these layouts i have a textview which contain a big text. what i need ur help in is how to set only the textview to scroll vertically no the whole layout.
here is my xml layout
enter code here
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/inner_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:background="#drawable/header"
android:paddingLeft="2dip"
android:paddingRight="2dip" >
<Button
android:id="#+id/sample_button"
style="#android:style/Widget.Button.Small"
android:layout_width="35dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:background="#drawable/burger" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/home_button" />
<TextView
android:id="#+id/breakARTISTNAME"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
<RelativeLayout
android:layout_width="250dp"
android:layout_height="374dp"
android:layout_marginBottom="6dp"
android:layout_marginLeft="35dp"
android:layout_marginTop="20dp"
android:background="#C71585" >
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:background="#drawable/add_schedule_bg"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageButton1"
android:layout_width="40dp"
android:layout_height="40dp"
android:paddingTop="3dp"
android:src="#drawable/add_button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageButton1"
android:paddingLeft="10dp"
android:text="add to my schedual"
android:textColor="#FFFFFF" />
</RelativeLayout>
<ImageView
android:id="#+id/breakARTISTIMAGE"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="14dp"
android:src="#drawable/ic_launcher" />
//here is the text i need only to be scrollalbe
<TextView
android:id="#+id/breakARTISTDESCRIPTION"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/breakARTISTIMAGE"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/breakARTISTIMAGE2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_above="#+id/breakARTISTDESCRIPTION"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
Try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/inner_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:background="#drawable/header"
android:paddingLeft="2dip"
android:paddingRight="2dip" >
<Button
android:id="#+id/sample_button"
style="#android:style/Widget.Button.Small"
android:layout_width="35dip"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dip"
android:background="#drawable/burger" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/home_button" />
<TextView
android:id="#+id/breakARTISTNAME"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
<RelativeLayout
android:layout_width="250dp"
android:layout_height="374dp"
android:layout_marginBottom="6dp"
android:layout_marginLeft="35dp"
android:layout_marginTop="20dp"
android:background="#C71585">
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:background="#drawable/add_schedule_bg"
android:orientation="vertical">
<ImageView
android:id="#+id/imageButton1"
android:layout_width="40dp"
android:layout_height="40dp"
android:paddingTop="3dp"
android:src="#drawable/add_button" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageButton1"
android:paddingLeft="10dp"
android:text="add to my schedual"
android:textColor="#FFFFFF" />
</RelativeLayout>
<ImageView
android:id="#+id/breakARTISTIMAGE"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="14dp"
android:src="#drawable/ic_launcher"/>
<ScrollView
android:id="#+id/breakSCROLLVIEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_below="#+id/breakARTISTIMAGE">
<TextView
android:id="#+id/breakARTISTDESCRIPTION"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"/>
</ScrollView>
<ImageView
android:id="#+id/breakARTISTIMAGE2"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_above="#+id/breakSCROLLVIEW"
android:layout_alignParentRight="true"
android:src="#drawable/ic_launcher"/>
</RelativeLayout>
</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