I want to scroll the images - android

I want to scroll the images in such a way that the back button is not scrolled. I am trying to take the back button above the scroll view but unable to find the solution. Please help. This is my code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/back" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/animal1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:src="#drawable/ant" />
<ImageButton
android:id="#+id/animal2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal1"
android:src="#drawable/bat" />
<ImageButton
android:id="#+id/animal3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal2"
android:src="#drawable/bear" />
<ImageButton
android:id="#+id/animal4"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal3"
android:src="#drawable/cheetah" />
<ImageButton
android:id="#+id/animal5"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_below="#+id/animal1"
android:src="#drawable/cow" />
<ImageButton
android:id="#+id/animal6"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_below="#+id/animal2"
android:layout_toRightOf="#+id/animal5"
android:src="#drawable/donkey" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
And now the button is going behind. Its getting hidden.

Solution of your question.
Step 1
Take a RelativeLayout as parent of your ScrollView. And set property to left assign to your ScrollView.
Step 2
Instead of placing ImageView at the end of your ScrollView, place it at Right Of your ScrollView.
Solution 1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical"
android:layout_toLeftOf="#+id/animal_back" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
...
</RelativeLayout>
</ScrollView>
I added android:layout_toLeftOf="#+id/animal_back" code. So that ImageView will be visible to right side. and ScrollView will be set to left side of ImageView.
Solution 2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
...
</RelativeLayout>
</ScrollView>
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>

Put back button outside from scroll view. And then adjust thier positions as you want.

Keep outside your back button of Scrollview, Can you just try below code#
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical" >
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/update" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/animal_back" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/animal1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:src="#drawable/icon" />
<ImageButton
android:id="#+id/animal2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_toRightOf="#+id/animal1"
android:layout_weight="1.0"
android:src="#drawable/icon" />
<ImageButton
android:id="#+id/animal3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_toRightOf="#+id/animal2"
android:layout_weight="1.0"
android:src="#drawable/icon" />
<ImageButton
android:id="#+id/animal4"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_toRightOf="#+id/animal3"
android:layout_weight="1.0"
android:src="#drawable/icon" />
<ImageButton
android:id="#+id/animal5"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="#+id/animal1"
android:layout_weight="1.0"
android:src="#drawable/icon" />
<ImageButton
android:id="#+id/animal6"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="#+id/animal2"
android:layout_toRightOf="#+id/animal5"
android:layout_weight="1.0"
android:src="#drawable/icon" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/back" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/animal1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:src="#drawable/ant" />
<ImageButton
android:id="#+id/animal2"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal1"
android:src="#drawable/bat" />
<ImageButton
android:id="#+id/animal3"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal2"
android:src="#drawable/bear" />
<ImageButton
android:id="#+id/animal4"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_toRightOf="#+id/animal3"
android:src="#drawable/cheetah" />
<ImageButton
android:id="#+id/animal5"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_below="#+id/animal1"
android:src="#drawable/cow" />
<ImageButton
android:id="#+id/animal6"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_weight="1.0"
android:layout_below="#+id/animal2"
android:layout_toRightOf="#+id/animal5"
android:src="#drawable/donkey" />
</RelativeLayout>
</ScrollView>

use frameLayout for your layout. this will help you to achieve what you want. Frame Layout details you can get here

I got the solution. I just need to bring the back button at front position by adding this line......
back.bringToFront();
Thanks all.

// try this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="4">
<ImageButton
android:id="#+id/animal1"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="1"
android:minWidth="200dp"
android:src="#drawable/ant" />
<ImageButton
android:id="#+id/animal2"
android:layout_width="0dp"
android:layout_height="200dp"
android:minWidth="200dp"
android:layout_weight="1"
android:src="#drawable/bat" />
<ImageButton
android:id="#+id/animal3"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="1"
android:minWidth="200dp"
android:src="#drawable/bear" />
<ImageButton
android:id="#+id/animal4"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_weight="1"
android:minWidth="200dp"
android:src="#drawable/cheetah" />
</LinearLayout>
<ImageButton
android:id="#+id/animal_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton
android:id="#+id/animal5"
android:layout_width="0dp"
android:minWidth="200dp"
android:layout_height="200dp"
android:layout_weight="1"
android:src="#drawable/cow" />
<ImageButton
android:id="#+id/animal6"
android:layout_width="0dp"
android:minWidth="200dp"
android:layout_height="200dp"
android:layout_weight="1"
android:src="#drawable/donkey" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

Related

Android XML - Unable to Prevent ImageView Overlap

I'm attempting to prevent two images from overlapping - and I though I'd be able to do so using two RelativeLayouts inside a LinearLayout - both set to wrap_content - however the two imageViews ( #+id/imageView1 - the boxart and #+id/background - the background) however they still seem to overlap.
Can someone spot what I may have done wrong in this implementation?
XML Source:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black" >
<RelativeLayout
android:id="#+id/rl_ListView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#color/black" >
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="#drawable/boxart"
android:gravity="left"
android:paddingBottom="65dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/background"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:background="#drawable/background_faded"
android:gravity="right"
android:paddingBottom="65dp"
android:scaleType="fitXY" />
</RelativeLayout>
<ImageView
android:id="#+id/downloadbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="200dp"
android:paddingLeft="500dp"
android:src="#drawable/button_download" />
<ProgressBar
android:id="#+id/progressbar_Horizontal"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="585dp"
android:layout_height="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="440dp"
android:layout_marginRight="100dp"
android:max="100"
android:progressDrawable="#drawable/progressbar2" />
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:background="#drawable/timeline_bottom_android"
android:orientation="horizontal" >
<ImageView
android:id="#+id/backbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:src="#drawable/icon_back_arrow" />
<TextView
android:id="#+id/backButtonTxt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignRight="#+id/saveButton"
android:gravity="center_vertical"
android:text="Movies"
android:textSize="40sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/downloadbtn"
android:layout_below="#+id/downloadbtn"
android:layout_marginRight="207dp"
android:layout_marginTop="110dp" />
</RelativeLayout>
</LinearLayout>
Screenshot:
Instead of using Relative layout use a Linear layout with orientation horizontal and then use two Linear layouts with layout_weight=1 for each ImageView. It will divide your screen into two equal parts horizontally.
For example :-
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical" />
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical" />
</LinearLayout>
As per your given layout update your layout as follows:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/rl_ListView2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/boxart"
android:paddingBottom="65dp" />
</LinearLayout >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/background"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:background="#drawable/background_faded"
android:gravity="right"
android:paddingBottom="65dp"
android:scaleType="fitXY" />
</RelativeLayout>
<ImageView
android:id="#+id/downloadbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:layout_marginTop="200dp"
android:paddingLeft="500dp"
android:src="#drawable/button_download" />
<ProgressBar
android:id="#+id/progressbar_Horizontal"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="585dp"
android:layout_height="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="440dp"
android:layout_marginRight="100dp"
android:max="100"
android:progressDrawable="#drawable/progressbar2" />
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:background="#drawable/timeline_bottom_android"
android:orientation="horizontal" >
<ImageView
android:id="#+id/backbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:src="#drawable/icon_back_arrow" />
<TextView
android:id="#+id/backButtonTxt"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignRight="#+id/saveButton"
android:gravity="center_vertical"
android:text="Movies"
android:textSize="40sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/downloadbtn"
android:layout_below="#+id/downloadbtn"
android:layout_marginRight="207dp"
android:layout_marginTop="110dp" />
</LinearLayout>
With regards to your particular situation, the 2 ImageViews causing problems are placed each in a RelativeLayout, which are also placed in a RelativeLayout. Views placed in a relative layout can overlap each other. So when you added the 2 children RelativeLayouts in the parent one, exactly this happened. To make one follow the other, you can add android:layout_toRightOf="#id/id_of_the_layout_you_want_on_the_left_of_this_one" to the second child.
Also, if you are willing to change your layout a bit, you could achieve this through weight and LinearLayout (note however that this will work only if the desired combined width of the 2 children is less than what the parent is willing to offer):
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
</LinearLayout>
</LinearLayout>

How do I create overlay button in my Android layout

I want to create a button which will overlay between 2 layouts.
I am using Linear Layout and added appropriate weight to it.
Have attached a screen shot for reference.
Here is my XML
tag.xml :
<?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:gravity="center"
android:orientation="vertical"
android:weightSum="100" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="30"
android:background="#color/greyColor"
android:gravity="center" >
<ImageView
android:id="#+id/ximgvwCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/camera_big" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="70"
android:background="#android:color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#android:color/white"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:padding="5dp"
android:text="#string/strQ1"
android:textAppearance="#android:style/TextAppearance.Medium"
android:textColor="#android:color/darker_gray" />
</LinearLayout>
</ScrollView>
Please help me in this.
Thanks in advance!
Try this it will working...
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp" >
<ImageView
android:id="#+id/imageCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/image_top" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:background="#drawable/image_bottom"
android:layout_height="match_parent" >
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageProfile"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="end"
android:layout_marginTop="100dp"
android:src="#drawable/ic_launcher" />
</FrameLayout>
View like this
You need a relative layout. Set image alignt to right-top and set margin top appropriately.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/first"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:src="#drawable/firstImage" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:src="#drawable/middleImage" >
</ImageView>
<RelativeLayout
android:id="#+id/second"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_below="#id/first"
android:src="#drawable/share_over" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/YES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/YES" />
<ImageView
android:id="#+id/NO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/NO" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Divide your image TOP-MIDDLE-BOTTOM(layout). Your size looking like above but
you can change width/height size.

TextView is not updated within RelativeLayout

I'm developing a custom camera app. CameraPreview takes a part of the screen, and the rest of the screen on the rightis allocated for control panel.
Now, when I change the shooting parameters, the text view and toggle views on the control panels are not updated. I guess this is because of the camera, but I have no clue what to do.
This is a screen shot:
the screen shot with messed textview
My layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/total_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="#+id/gen_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#AA8888">
<FrameLayout
android:id="#+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
<RelativeLayout
android:id="#+id/overlay_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/topLeftMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_left_top_corner"
android:tag="mark" />
<ImageView
android:id="#+id/bottomLeftMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_left_bottom_corner"
android:tag="mark" />
<ImageView
android:id="#+id/topRightMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_right_top_corner"
android:tag="mark" />
<ImageView
android:id="#+id/bottomRightMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_right_bottom_corner"
android:tag="mark" />
<ImageView
android:id="#+id/leftCrop"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/rightCrop"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/upperCrop"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/bottomCrop"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
</RelativeLayout>
</FrameLayout> <!-- GEN_VIEW END -->
<RelativeLayout
android:id="#+id/whparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true">
<include layout="#layout/wheel_panel"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/adLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="bottom"
android:layout_toLeftOf="#id/whparent"
android:layout_alignTop="#id/whparent"
>
</RelativeLayout>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#id/whparent"
android:layout_margin="10dp"
android:text="#string/hello"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/control_panel"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Pocket Viewfinder" />
<TextView
android:id="#+id/viewAngle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/hello"
android:textSize="10sp" />
<TextView
android:id="#+id/widerWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/wWarning"
android:textColor="#color/warning_color"
android:textSize="10sp"
android:visibility="invisible" />
<Button
android:id="#+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/capture_button" />
<ToggleButton
android:id="#+id/booster_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textOff="#string/booster_off"
android:textOn="#string/booster_on" />
</LinearLayout>
</RelativeLayout> <!-- TOTAL_VIEW END -->
</RelativeLayout>
Everytime the TextView text is changed, I call:
controlPanelView.requestLayout();
But the controlPanelView is not updated at all.
What am I doing wrong? THNX

How to obtain this xml android layout

I've seen this layout ( http://cdn0.tnwcdn.com/wp-content/blogs.dir/1/files/2014/03/Instaedit1.jpg ) and i wanna do somthing like that but i don't know what i have to do to obtain that result.
i've tried with a relative layout which contains a imageview and a gridlayout which contains three imagebutton.
<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"
tools:context="com.example.prova.MainActivity$PlaceholderFragment" xmlns:app="http://schemas.android.com/apk/res/com.example.prova">
<ImageView
android:id="#+id/imageView1"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/profile" />
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/imageView1"
app:columnCount="3"
app:orientation="horizontal"
app:rowCount="1"
app:useDefaultMargins="false" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="fill_horizontal"
android:scaleType="center"
android:src="#drawable/friend" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="fill_horizontal"
android:maxHeight="100dp"
android:src="#drawable/fotocamera" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/eventi" />
</android.support.v7.widget.GridLayout>
</RelativeLayout>
But i don't obtain the same result of the top of the image.
I've tried changing the gravity value and width value but nothing.
Can you help me??? (sorry for my bad english :P Thanks).
I worked on your code to obtain this: http://it.tinypic.com/view.php?pic=2aj1cms&s=8#.UyhKXtT5OBM
It's a better result but i don't understand why there are s space between the imagebutton.
My code is this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res/com.example.prova"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.prova.MainActivity$PlaceholderFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="3" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="3" >
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/friend" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/fotocamera" />
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/eventi" />
</LinearLayout>
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Aggiungi agli amici" />
</LinearLayout>
</LinearLayout>
Any idea??

Align to the right of the screen with margin Android

I have a Linearlayout within a RelativeLayout that I'm trying to align to the rightmost side of the screen with margin. Example:
How should I modify the LinearLayout's properties to achieve this? thanks
Here is the XML file(the name of the LinearLayout that should be aligned to right is slide_right):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="top"
tools:context=".MainActivity" >
<WebView android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:id="#+id/slide_left"
android:layout_width="400dp"
android:layout_height="550dp"
android:layout_marginLeft="-367dp"
android:layout_marginTop="150dp"
android:background="#drawable/left_slide"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/slide_right"
android:layout_width="400dp"
android:layout_height="550dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="-30dp"
android:orientation="horizontal"
android:background="#drawable/right_slide">
</LinearLayout>
<LinearLayout
android:id="#+id/header_linear_l"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/mapbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/mapbt" />
<ImageButton
android:id="#+id/profilebt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/profilebt" />
<ImageButton
android:id="#+id/settingsbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/settingsbt" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/optionalbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/optionbt" />
<ImageButton
android:id="#+id/lvlbt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/levelbt" />
</LinearLayout>
<ProgressBar
android:id="#+id/experiencebar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="#+id/Attack_Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/slide_left"
android:layout_marginBottom="129dp"
android:layout_marginLeft="36dp"
android:layout_toRightOf="#+id/slide_left"
android:src="#drawable/ic_launcher_old"
android:visibility="invisible" />
</RelativeLayout>
Change Your Relative layout's Property
from
android:layout_width="wrap_content"
to
android:layout_width="match_parent"
thats it... (definitely I have tested it see below snapshot)
See the following Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/your_relative_layout_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white" >
<LinearLayout
android:id="#+id/your_linear_layout_id"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="-30dip"
android:background="#e42c2a"
android:orientation="horizontal" >
</LinearLayout>
</RelativeLayout>
Here
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="-30dip"
are of your use.

Categories

Resources