how can i put the framelayout in the bottom of the application? - android

i want to put a framelayout in the bottom by doing this :
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/darkblue"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bottom"
android:textSize="30px"
android:textColor="#color/white"
android:layout_gravity="center"
/>
</FrameLayout>
But it doesn't work . It's staying in the middle of my application.
This is the whole thing :
<?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="fill_parent"
android:background="#color/white"
>
<FrameLayout
android:id="#+id/first"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/darkblue"
>
<ImageView
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:src="#drawable/back4"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="30px"
android:textColor="#color/white"
android:layout_gravity="center"
/>
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:id="#+id/second"
android:layout_below="#id/first"
>
<ImageView
android:id="#+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/chuck"
/>
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:id="#+id/third"
android:layout_below="#id/second"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="#+id/sum"
android:text="Summary "
android:textSize="25px"
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/s_btn"
android:src="#drawable/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/sum"
android:layout_alignTop="#id/sum"
/>
<TextView
android:id="#+id/blank"
android:text=" "
android:textSize="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/sum"
/>
<TextView
android:id="#+id/airdate"
android:text="Air Date : "
android:textSize="25px"
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/blank"
/>
<TextView
android:id="#+id/blank2"
android:text=" "
android:textSize="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/airdate"
/>
<TextView
android:id="#+id/airtime"
android:text="Air Time : "
android:textSize="25px"
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/blank2"
/>
</RelativeLayout>
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/darkblue"
android:id="#+id/fourth"
android:layout_below="#id/third"
android:layout_alignParentBottom="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bottom"
android:textSize="30px"
android:textColor="#color/white"
android:layout_gravity="center"
/>
</FrameLayout>
</RelativeLayout>

In the bottom of what? What is your parent layout? If you're using a RelativeLayout, remove the layout_gravity attribute, and add the alignParentBottom="true" attribute instead.

Not sure this is totally correct but I'm working on an similar app with a bunch of frame layouts that get dynamically generated and had to switch to relative layouts to use the android:layout_below="#id/some_id" to 'stack' my layouts. I'm using fragments and it seems to be working well.
Example layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/bg">
<!-- Content Foo -->
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/middle_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#id/top_layout"
android:background="#drawable/bg">
<!-- Content Foo -->
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/bottom_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="#id/middle_layout"
android:background="#drawable/bg">
<!-- Content Foo -->
</RelativeLayout>

This is full programmability method :
EKRAN MY_EKRAN;
context = getApplicationContext();
MY_EKRAN = new EKRAN( contex );
YOUR_FRAMELAYOUT = findViewById(R.id.PUT_ID_FOR_YOUR_FRAMELAYOUT);
YOUR_FRAMELAYOUT.post(new Runnable() {
#Override
public void run() {
YOUR_FRAMELAYOUT.getLayoutParams().width = MY_EKRAN.W(105);
YOUR_FRAMELAYOUT.getLayoutParams().height = MY_EKRAN.H(10);
// banner.getLayoutParams().width = ( MY_EKRAN.H(10));
// banner.getLayoutParams().width = ( MY_EKRAN.H(10));
YOUR_FRAMELAYOUT.setY( MY_EKRAN.H(90) );
// also like this
// YOUR_FRAMELAYOUT.setLayoutParams(new LinearLayout.LayoutParams( MY_EKRAN.W(100) ,MY_EKRAN.H(30) ));
}
});
Here's ekran class :
public class EKRAN {
DisplayMetrics dm = new DisplayMetrics();
Point size_ = new Point();
static int width;
static int height;
EKRAN(Context CONTEXT_) {
dm = CONTEXT_.getResources().getDisplayMetrics();
int densityDpi = dm.densityDpi;
height = dm.heightPixels;
width = dm.widthPixels;
}
public static int WIDTH() {
return width;
}
public static int HEIGHT(){
return height;
}
public int W( int PER_ ){
return width/100*PER_;
}
public int H( int PER_ ){
return height/100*PER_;
}
//////////////////
//extras
/////////////////
public int GET_PIX_FROM_DP ( float DP_VALUE )
{
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DP_VALUE , dm );
}
public int GET_PIX_FROM_DP2 ( float DP_VALUE )
{
float res = DP_VALUE * ( dm.ydpi / 160f);
return (int) res;
}
}

Related

textview is not displayed in gallery item and also there is space at beginning and end of every item

I want to display imageview and textview as a verticle item in gallery but textview is not displayed and also before first item and last item of gallery it contains space, how can I remove this space?
This is my code.
FilterActivity.java
public class FilterActivity extends Activity {
ListView lstfilter;
MyAdapter adapter;
ImageView next,prev;
Gallery horizontalscrollview;
public static ArrayList<String> mylist;
public static ArrayList<String> mycategorylist;
HorizontalScrollView horizontalScroll;
HorizontalScrollAdapter horizonAdapter;
LinearLayout hlayout;
ArrayList<Integer> array_image = new ArrayList<Integer>();
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_filter);
mylist = new ArrayList<String>();
mycategorylist = new ArrayList<String>();
horizontalscrollview = (Gallery) findViewById(R.id.horizontalscrollview);
horizontalscrollview.setHorizontalFadingEdgeEnabled(false);
hlayout = (LinearLayout)findViewById(R.id.horizontal_menu);
prev = (ImageView)findViewById(R.id.imgprev);
next = (ImageView) findViewById(R.id.imgnext);
lstfilter = (ListView) findViewById(R.id.lstfilter);
mylist.add("Rs.250 n Below(253 result found)");
mylist.add("Rs.251 - 500(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mylist.add("Rs.501 - 750(25301 result found))");
mycategorylist.add("Brand");
mycategorylist.add("Price");
mycategorylist.add("Discount");
mycategorylist.add("Availability");
mycategorylist.add("More");
array_image.add(R.drawable.img_brand);
array_image.add(R.drawable.img_rupee);
array_image.add(R.drawable.img_discount);
array_image.add(R.drawable.yellow_check_mark);
array_image.add(R.drawable.yellow_check_mark);
horizonAdapter = new HorizontalScrollAdapter(this, mycategorylist,array_image);
horizontalscrollview.setAdapter(horizonAdapter);
// Getting adapter by passing xml data ArrayList
prev.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
horizontalscrollview = (Gallery) findViewById(R.id.horizontalscrollview);
int firstVisibleItem = horizontalscrollview.getFirstVisiblePosition();
int lastVisibleCount = horizontalscrollview.getLastVisiblePosition();
if (firstVisibleItem != 0) {
int count1 = firstVisibleItem
- (lastVisibleCount - firstVisibleItem);
if (count1 < 0) {
horizontalscrollview.setSelection(0);
}
else {
horizontalscrollview.setSelection(count1);
}
Log.d("item selected:",""+count1);
if(count1 == 0)
{
Log.d("first item visible","");
prev.setVisibility(ImageView.GONE);
next.setVisibility(ImageView.VISIBLE);
}
else
{
prev.setVisibility(ImageView.VISIBLE);
next.setVisibility(ImageView.GONE);
}
}
}
});
next.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
// horizontalScroll.scrollTo(
// (int) horizontalScroll.getScrollX() + 10,
// (int) horizontalScroll.getScrollY());
horizontalscrollview = (Gallery) findViewById(R.id.horizontalscrollview);
int count = horizontalscrollview.getCount();
int firstVisibleItem = horizontalscrollview.getFirstVisiblePosition();
int lastVisibleCount = horizontalscrollview.getLastVisiblePosition();
if (lastVisibleCount != count) {
int count1 = lastVisibleCount
+ (lastVisibleCount - firstVisibleItem);
if (count1 > count) {
horizontalscrollview.setSelection(count);
} else {
horizontalscrollview.setSelection(count1);
}
Log.d("item selected:",""+lastVisibleCount);
if(count1 == lastVisibleCount)
{
Log.d("last item visible","");
prev.setVisibility(ImageView.VISIBLE);
next.setVisibility(ImageView.GONE);
}
else
{
prev.setVisibility(ImageView.VISIBLE);
next.setVisibility(ImageView.GONE);
}
}
}
});
adapter = new MyAdapter(this, mylist);
lstfilter.setAdapter(adapter);
}
activity_filter.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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="#0088cc"
android:gravity="center_vertical"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.10" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:background="#null"
android:scaleType="fitCenter" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25" />
<ImageButton
android:id="#+id/imgDeliveryBack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.28"
android:background="#null"
android:padding="5dp"
android:scaleType="fitCenter"
android:src="#drawable/img_back_arrow" />
<TextView
android:id="#+id/txvdeliveryheader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:fontFamily="Roboto regular"
android:gravity="left|center"
android:text="Filter"
android:textColor="#f8f8f8"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".9"
android:gravity="left|center"
android:text="#null"
android:textColor="#ffffff" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgprev"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#3374a3"
android:src="#drawable/img_back_arrow" />
<LinearLayout
android:id="#+id/horizontal_menu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:background="#168fcc"
android:orientation="horizontal" >
<Gallery
android:id="#+id/horizontalscrollview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:background="#drawable/selected"
android:columnWidth="70dp"
android:fadingEdgeLength="0dp"
android:horizontalSpacing="5dp"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" />
</LinearLayout>
<ImageView
android:id="#+id/imgnext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:background="#3374a3"
android:src="#drawable/img_next" />
</LinearLayout>
<ListView
android:id="#+id/lstfilter"
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="40dp"
android:layout_weight="0.3" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#035f8d" >
<TextView
android:id="#+id/txvremove"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:padding="5dp"
android:src="#drawable/icon_trash_white"
android:text="#string/clear_filters"
android:textColor="#ffffff"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#000000" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:padding="5dp"
android:src="#drawable/icon_trash_white"
android:text="APPLY"
android:textColor="#ffffff"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
activity_horizontal_item.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="wrap_content"
android:background="#168fcc"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgcategory"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/txvcategoryname"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#066da1" />
</LinearLayout>
</LinearLayout>
HorizontalScrollAdapter.java
public class HorizontalScrollAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<String> data;
ArrayList<Integer> image;
private static LayoutInflater inflater = null;
// public ImageLoader imageLoader;
public HorizontalScrollAdapter(Activity a, ArrayList<String> list,ArrayList<Integer> image_array) {
activity = a;
data = list;
image = image_array;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.activity_horizontal_item, null);
TextView txvfirst = (TextView) vi.findViewById(R.id.txvcategoryname); // title
ImageView imgcategory = (ImageView) vi.findViewById(R.id.imgcategory);
// HashMap<String, String> song = new HashMap<String, String>();
// song = data.get(position);
// Setting all values in listview
// title.setText(song.get(CustomizedListView.KEY_TITLE));
// artist.setText(song.get(CustomizedListView.KEY_ARTIST));
// duration.setText(song.get(CustomizedListView.KEY_DURATION));
// imageLoader.DisplayImage(song.get(CustomizedListView.KEY_THUMB_URL),
// thumb_image);
txvfirst.setText(data.get(position));
imgcategory.setImageResource(image.get(position));
return vi;
}
how can I display text below each image of gallery and I also want to remove space before and after each gallery item.
Actually in your activity_filter.xml layout, the parent layout(LinearLayout here) for Gallery widget is having a fixed height of 40dp, if increase it or handle it with weights or something it will show the TextView. You can see, here I have increased that height to 100dp and it shows the TextView clearly. And the space is coming because you have given horizontalSpacing as 5dp, trying reducing that if you don't want the spaces between column.
UPDATE:-
I have updated my answer to remove spaces around Gallery, Here I have RelativeLayout and now the Prev and Next buttons are overlapping with gallery. Hope it solves your problem.
<?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:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="#0088cc"
android:gravity="center_vertical"
android:orientation="horizontal" >
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.10" />
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:background="#null"
android:scaleType="fitCenter" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25" />
<ImageButton
android:id="#+id/imgDeliveryBack"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.28"
android:background="#null"
android:padding="5dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_action_pass" />
<TextView
android:id="#+id/txvdeliveryheader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:fontFamily="Roboto regular"
android:gravity="left|center"
android:text="Filter"
android:textColor="#f8f8f8"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".9"
android:gravity="left|center"
android:text="#null"
android:textColor="#ffffff" >
</TextView>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/horizontal_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#168fcc"
android:orientation="horizontal" >
<Gallery
android:id="#+id/horizontalscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/drawer_shadow"
android:columnWidth="70dp"
android:fadingEdgeLength="0dp"
android:horizontalSpacing="5dp"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" />
</LinearLayout>
<ImageView
android:id="#+id/imgprev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_action_pass" />
<ImageView
android:id="#+id/imgnext"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:src="#drawable/ic_action_like" />
</RelativeLayout>
<ListView
android:id="#+id/lstfilter"
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="40dp"
android:layout_weight="0.3" >
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#035f8d" >
<TextView
android:id="#+id/txvremove"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:padding="5dp"
android:src="#drawable/ic_action_pass"
android:text="#string/abc_action_bar_home_description"
android:textColor="#ffffff"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#000000" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:padding="5dp"
android:src="#drawable/ic_action_like"
android:text="APPLY"
android:textColor="#ffffff"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>

Nothing show after use canvas

I am trying to draw lines and rectangles and the line works perfectly, but when I try to draw the rectangles they doesn't show, so I commented the method and put the rectangles in the background of the layouts, but even they didn't show.
MainActivity.class
protected void onCreate (Bundle savedInstanceState {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
line = (LinearLayout)findViewById(R.id.line);
doLine DoLine = new doLine(line.getContext (),0.2,0.4,0.4);
line.addView(DoLine);
}
DoLine.class
public DoLine (Context context, double first, double second, double third){
super (context);
one = first;
two = second;
three = three;
}
#SuppressLink("DrawAllocation")
public void onDraw (Canvas canvas){
canvas.drawRGB (255,255,255);
Paint pincel1 = new Paint;
pincel1.setColor(getResources().getColor(R.color.yellow));
canvas.drawRect(0,10, getWidth(),40,pincel1);
pincel1.setColor(getResources().getColor(R.colot.green));
canvas.drawRect((float)(getWidth()*one),10, getWidth(),40,pincel1);
pincel1.setColor(getResources().getColor(R.color.blue));
canvas.drawRect((float)(getWidth()*one),10, (float)(getWidth()-(getWidth()*three)),40, pincel1);
activity_main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dcdcdc"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="#fdfdfd"
android:orientation="vertical"
android:padding="3dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="#90ffb200"
android:padding="5dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:gravity="right"
android:text="#string/title"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<LineraLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal
<LinearLayout
android:id="#+id/rectyellow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/yellow
</LinearLayout>
<TextView
android:id="#+id/oneText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
<LinearLayout
android:id="#+id/rectblue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/blue"
</LinearLayout>
<TextView
android:id="#+id/twoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
<LinearLayout
android:id="#+id/rectgreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/green"
</LinearLayout>
<TextView
android:id="#+id/threeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have been researching for many many days to find a solution and today i found it, I just needed to change the height of the layout to 40dp
android:layout_height="wrap_content"// change this to 40dp
mainActivity.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dcdcdc"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="#fdfdfd"
android:orientation="vertical"
android:padding="3dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="#90ffb200"
android:padding="5dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:gravity="right"
android:text="#string/title"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="wrap_content"// change this to 40dp
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5dp">
<LineraLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal
<LinearLayout
android:id="#+id/rectyellow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/yellow
</LinearLayout>
<TextView
android:id="#+id/oneText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="one" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
<LinearLayout
android:id="#+id/rectblue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/blue"
</LinearLayout>
<TextView
android:id="#+id/twoText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="two" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
<LinearLayout
android:id="#+id/rectgreen"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:background="#drawable/green"
</LinearLayout>
<TextView
android:id="#+id/threeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
https://www.dropbox.com/s/8dvmgv1k37tnm9f/Sin%20t%C3%ADtulo.png
it's right:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout line = (LinearLayout)findViewById(R.id.line);
DoLine doLine = new DoLine(line.getContext (),0.2,0.4,0.4);
line.addView(doLine);
}
public class DoLine extends View {
double one;
double two;
double three;
public DoLine(Context context, double first, double second, double third) {
super(context);
one = first;
two = second;
three = third;
}
#SuppressLint("DrawAllocation")
public void onDraw(Canvas canvas) {
canvas.drawRGB(255, 255, 255);
Paint pincel1 = new Paint();
pincel1.setColor(Color.YELLOW);
canvas.drawRect(0, 10, getWidth(), 40, pincel1);
pincel1.setColor(Color.GREEN);
canvas.drawRect((float) (getWidth() * one), 10, getWidth(), 40, pincel1);
pincel1.setColor(Color.BLUE);
canvas.drawRect((float) (getWidth() * one), 10, (float) (getWidth() - (getWidth() * three)), 40, pincel1);
}
}
}

Slide In View Animation

I want a relative layout to slide into a screen.
At the moment I set the layout to be below a layout that takes up the whole screen
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/ghostIv"
android:src="#drawable/results_ghost"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
<ImageView
android:id="#+id/ghostShadowIv"
android:visibility="gone"
android:src="#drawable/results_ghost_shadow"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ghostIv"/>
<TextView
android:id="#+id/noFilterTv"
android:textStyle="bold"
android:gravity="center_horizontal"
android:textColor="#color/LightTextGrey"
android:visibility="gone"
android:text="#string/no_filters"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:layout_centerHorizontal="true"
android:layout_below="#+id/ghostShadowIv"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<com.allryder.android.ui.views.ScheduleView
android:visibility="invisible"
android:background="#color/White"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scheduleView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"/>
<View
android:id="#+id/shadowV"
android:visibility="gone"
android:layout_above="#+id/ratingRl"
android:layout_height="4dp"
android:layout_width="match_parent"
android:background="#drawable/bottom_shadow"/>
<RelativeLayout
android:id="#+id/ratingRl"
android:layout_below="#+id/scheduleView"
android:background="#color/White"
android:clickable="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:background="#drawable/time_view_selector"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/ratePromptTv"
android:layout_toLeftOf="#+id/closeRatingIv"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:text="#string/rate_prompt"/>
<ImageView
android:background="#drawable/time_view_selector"
android:padding="10dp"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/ratePromptTv"
android:layout_alignBottom="#+id/ratePromptTv"
android:id="#+id/closeRatingIv"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="#drawable/search_clear"/>
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
<fragment android:id="#+id/filters_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:name="com.allryder.android.ui.fragments.FiltersDrawerFragment"/>
Then make this call
ratingRl.animate().translationY(- ratingRl.getHeight());
But it doesn't slide into the screen. If the view is in the screen to start off with, the view does animate. What is the problem?
ratingRl.animate().translationY(- ratingRl.getHeight()).setDuration(300).start();
I have done similar task in my recent project.
background = (RelativeLayout) findViewById(R.id.slidingBackground);
positionOffScreen(background);
private void positionOffScreen(View v){
View myView = v;
int amountOffscreen = (int)(getScreenWidth());
boolean offscreen = true;
int xOffset = (offscreen) ? amountOffscreen : 0;
RelativeLayout.LayoutParams rlParams = (RelativeLayout.LayoutParams)myView.getLayoutParams();
rlParams.setMargins(-1*xOffset, 0, xOffset, 0);
myView.setLayoutParams(rlParams);
}
protected float getScreenWidth() {
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
return (float) displaymetrics.widthPixels;
}
When you want to start animation call this method
private void startAnimation(int duration){
TranslateAnimation a = new TranslateAnimation(Animation.ABSOLUTE,0,Animation.ABSOLUTE,getScreenWidth(),Animation.ABSOLUTE,0,Animation.ABSOLUTE,0);
a.setDuration(duration);
a.setFillAfter(false);
background.startAnimation(a);
}
When you want to interrupt animation
background.clearAnimation();
Here is layout example. The sliding view has to be placed on RelativeLayout.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background" >
<RelativeLayout
android:id="#+id/slidingBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#64000000"
android:orientation="vertical" >
</RelativeLayout>
...
And this is the app link where I use this sliding view.

buttons on frame layout

Hi I am developing an android video app. I have buttons on my frame layout. I need the buttons a little big. But they are getting shrinked as I get the preview on the screen.
Video.xml looks as below
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<FrameLayout
android:id="#+id/videoview"
android:layout_width="720px"
android:layout_height="480px" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/mybutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:src="#drawable/record_video" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="#+id/flashoff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="OFF"
android:textSize="8dp" />
<RadioButton
android:id="#+id/flashtorch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Torch"
android:textSize="8dp" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
and the oncreate is as below
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.videocapture);
DisplayMetrics metrics = this.getResources().getDisplayMetrics();
vwidth = metrics.widthPixels;
vheight = metrics.heightPixels;
Log.e("vwidth"," "+vwidth);
Log.e("vheight"," "+vheight);
//Get Camera for preview
myCamera = getCameraInstance();
if(myCamera == null)
{
Toast.makeText(VideoCapture.this,"Fail to get Camera",Toast.LENGTH_LONG).show();
}
myCameraSurfaceView = new MyCameraSurfaceView(this, myCamera);
final FrameLayout myCameraPreview = (FrameLayout)findViewById(R.id.videoview);
myCameraPreview.addView(myCameraSurfaceView);
myCameraPreview.post(new Runnable()
{
#Override
public void run()
{
int width = vwidth;
int height = vheight;
LayoutParams lp = myCameraPreview.getLayoutParams();
lp.height = height;
lp.width = width - 80;
myCameraPreview.setLayoutParams(lp);
}
});
recVideo = (ImageView)findViewById(R.id.mybutton);
recVideo.setOnClickListener(myButtonOnClickListener);
flashOff = (RadioButton)findViewById(R.id.flashoff);
flashTorch = (RadioButton)findViewById(R.id.flashtorch);
}
How do I resolve this. Please Help. Thanks
Try to use this layout , you can change weight according to your requirement.Please change background colors .Hope it will help.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<FrameLayout
android:id="#+id/videoview"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#FFCCCC" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#99FF66"
android:orientation="vertical" >
<ImageView
android:id="#+id/mybutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:src="#drawable/ic_launcher" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="#+id/flashoff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="OFF"
android:textSize="8dp" />
<RadioButton
android:id="#+id/flashtorch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Torch"
android:textSize="8dp" />
</RadioGroup>
</LinearLayout>
</LinearLayout>

Android - Adding horizontal scroll in a layout with multiple Items

I want to create a layout which has multiple views in it. Currently I have 3tabs, in one of which I want to be able to scroll a specific part of the layout which contains two textviews and an Image.
I have tried using ViewPager , HorizontalScrollView but I havenot been able to scroll this part of my layout. Here is a design of my layout
[some images][scroll view]
[table 1]
[table 2]
[tab1][tab2][tab3]
the code that I have ran for gesture detection
public class RegionView extends HorizontalScrollView implements View.OnTouchListener{
private static final int SWIPE_MIN_DISTANCE = 5;
private static final int SWIPE_THRESHOLD_VELOCITY = 300;
private ArrayList<ArticleList> mItems= new ArrayList<ArticleList>();
private GestureDetector mGestureDetector;
private int mActiveFeature = 0;
public RegionView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setItems();
// TODO Auto-generated constructor stub
}
public RegionView(Context context) {
super(context);
internalWrapper = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
internalLayout = (LinearLayout) findViewById(R.id.regionll1);
featureLayout = (LinearLayout) View.inflate(myContext,R.layout.regionview1,null);
setItems();
}
public void setItems(){
showToast("setItem Called");
internalLayout.setOnTouchListener(gestureListener);
for(int i = 0; i< mItems.size();i++){
internalLayout.addView(featureLayout);
}
setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
if (mGestureDetector.onTouchEvent(event)) {
return true;
}else if(event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL ){
int scrollX = getScrollX();
int featureWidth = v.getMeasuredWidth();
mActiveFeature = ((scrollX + (featureWidth/2))/featureWidth);
int scrollTo = mActiveFeature*featureWidth;
smoothScrollTo(scrollTo, 0);
return true;
}else{
return false;
}
}
});
mGestureDetector = new GestureDetector(new MyGestureDetector());
}
class MyGestureDetector extends SimpleOnGestureListener {
public boolean isRightToLeft = false;
#Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
int featureWidth = getMeasuredWidth();
mActiveFeature = (mActiveFeature < (mItems.size() - 1))? mActiveFeature + 1:mItems.size() -1;
smoothScrollTo(mActiveFeature*featureWidth, 0);
isRightToLeft=true;
return true;
}else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
int featureWidth = getMeasuredWidth();
mActiveFeature = (mActiveFeature > 0)? mActiveFeature - 1:0;
smoothScrollTo(mActiveFeature*featureWidth, 0);
showToast("Gesture on right swipe");
isRightToLeft=false;
return true;
}
} catch (Exception e) {
Log.e("Fling", "There was an error processing the Fling event:" + e.getMessage());
}
return false;
}
}
}
My XML file with the tabhost , I have splitted the code in 2 parts to show the place where I am implementing the Horizontalscroll view
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/main_bckground"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</RelativeLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/Orange"
>
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--First Tab-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabyourcity"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingLeft="0dip"
android:paddingRight="0dip" >
</LinearLayout>
<!—Second Tab-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabnepal"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:id = "#+id/nepalpageview"
android:orientation="vertical">
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/loadContainernepal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#414141"
android:orientation="horizontal" >
<TextView
android:id="#+id/loadingTextnepal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Data is Loading...."
android:textColor="#FFF"
/> <ProgressBar
android:id="#+id/progressBar2Nepal"
android:layout_width="25dip"
android:layout_height="25dip"
android:indeterminate="true"
android:visibility="visible"
android:layout_marginLeft="160dip"
style="#android:style/Widget.ProgressBar.Small"
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativelayouttop"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tv_sunrisetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_sunrise"
android:layout_alignRight="#+id/tv_sunrise"
android:layout_below="#+id/tv_sunrise"
android:gravity="center"
android:text="rise time"
android:textColor="#ffffff" />
<TextView
android:id="#+id/tv_sunrise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/img_SUNRISE"
android:layout_marginLeft="20dp"
android:gravity="center"
android:text="SUNRISE"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/Orange"
android:textSize="18sp" >
</TextView>
<ImageView
android:id="#+id/img_SUNRISE"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/tv_sunrise"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/tv_sunrise"
android:paddingTop="5dp"
android:src="#drawable/sunriseicon" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/img_sunset"
android:layout_alignRight="#+id/img_sunset"
android:layout_below="#+id/img_sunset"
android:gravity="center"
android:text="SUNSET"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/Orange"
android:textSize="18sp" />
<TextView
android:id="#+id/tv_sunsettime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tv_sunrise"
android:layout_alignRight="#+id/tv_sunrise"
android:layout_below="#+id/TextView02"
android:gravity="center"
android:text="SET time"
android:textColor="#ffffff" />
<ImageView
android:id="#+id/img_sunset"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignLeft="#+id/tv_sunrisetime"
android:layout_alignRight="#+id/tv_sunrisetime"
android:layout_below="#+id/tv_sunrisetime"
android:src="#drawable/sunseticon" />
<RelativeLayout
android:layout_width="130dp"
android:layout_height="120dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:gravity="right" >
<android.support.v4.view.ViewPager
android:id="#+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<HorizontalScrollView
android:id="#+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
the code works fine when I give all the image and text field in this layout,
but since I need to check the value and then place the texts and image here while scrolled I’m having a problem implementing this
<!-- <LinearLayout
android:id="#+id/scroll_linearlayout "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/regionll1 "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_regionname"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hilly Region"
android:textColor="#ffffff"
android:textSize="18sp" />
<ImageView
android:id="#+id/img_region"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:src="#drawable/iconsresized5" />
<TextView
android:id="#+id/tv_regiontemp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:id="#+id/regionll2 "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="#+id/regionll3 "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout> -->
</HorizontalScrollView>
</android.support.v4.view.ViewPager>
</RelativeLayout>
</RelativeLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dp"
android:background="#color/Orange"
android:gravity="center" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="25dp"
android:layout_height="20dp"
android:src="#drawable/rainfall_stastastics" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="Rainfall Statistics"
android:textColor="#ffffff"
android:textSize="16sp" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/tbl_background" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="4dp"
android:layout_height="wrap_content"
android:src="#drawable/bullet" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total this month to date "
android:textColor="#000000" />
<TextView
android:id="#+id/tv_totalrainfall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</TableRow>
<TableRow>
</TableRow>
</TableLayout>
<TableLayout>
</TableLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
</TabHost>
I want a scrollview like the one we get with iphone by viewpager

Categories

Resources