Customize position of handle of sliding drawer - java

I had researched many sources and tried but still cannot move the position of handle from center to right.
<SlidingDrawer
content >
<ImageButton <-- this is handle
android:id="#+id/handle" <-- i want to customize position
android:layout_width="50px"
android:layout_height="60px"
android:background="#drawable/icon_other" />
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_others"
android:orientation="vertical" >
//content
</LinearLayout>
</SlidingDrawer>
So what to do to customize the position?
Please give opinion. Thanks

Use a TableLayout. This works similar to a HTML Table concept, allowing you to define rows and columns where to place buttons and other components.
If you don't want to use a table layout for the entire screen, you should be able to nest the layout within another....

Related

How to make a layout in android that sticks to the bottom of the screen until the scrollview is scrolled to a certain position it gets scroll too?

I want to make a android activity screen where a layout is sticked to bottom until scrollview get scroll to a certain position. like in this video samples links:
https://drive.google.com/open?id=0B14wNBitoI33LWtUNThqcXRIUWc
https://drive.google.com/open?id=0B14wNBitoI33QW1BOGR1di1TcGc
amarjain07's StickyScrollView maybe a solution you would want to look into. His methodology of assigning the "sticky" views as identified attributes in the layout xml is quite a nifty feature IMHO.
Use a RelativeLayout and put the Button-Container inside it.
Pass the container in your_scrollview_activity.xml the following attribute
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1 (reft)" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 2 (right)"/>
</LinearLayout>
</RelativeLayout>
NOTE: You need to set a listener in your activity to get the ScrollViews current position / current height. With this current height you can calculate the "left space" to the bottom / end of the ScrollView. If your RelativeLayout reaches the bottom or if it's close to the bottom AND within the visible area, then call your animation.

Google Play Store Cardview

I have been trying for a long time to make Cards similar to appearance that of Google Play Store, ie cards of Different sizes , with images and all inside the card. Any tips on how to proceed.
Basically you just create a layout (RelativeLayout, LinearLayout, etc) as a child of your cardview element and make it look however you want.
For example...
<android.support.v7.widget.CardView
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardElevation="2dp"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="2dp">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
//Your desired layout here
</RelativeLayout>
</android.support.v7.widget.CardView>
You can take a look at the MaterialList implementations for some good examples.

using the <include/> in android programming

I am making an app, and I have the following XML file:
<?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="vertical"
android:background="#f4f4f4" >
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="325dp" />
<Button
android:id="#+id/add_claim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Claim" />
</LinearLayout>
I made a button called View_list that wants to see only the expandable list view on the entire page. what I did is create a new XML file, and added the follwing include statement:
<include android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
However, I realized that this will now work for two reasons
1 - There is no layout ID
2- I only want the list, not the button and everything else I am going to put in the original layout. What is going to happen is if I add something to the list, I need to be able to view it without the option of adding antthing to it.
My question is therefore this:
How do I find the layout ID and how can I prevent the entire layout from showing, and only show the list. I would really appreciate some advice.
The include should say:
<include layout="#layout/View_list"
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
This includes the View_list.xml layout in another layout.
But I dont really understand why you would use an include here if you don't want to re-use the whole layout, but only the list part of it. includes exist to easily use layouts in other layouts, if you need just a ListView, use just a ListView.
EDIT: I'm not sure anymore if I got your question right, but I'll not delete the answer because you commented on it.
If you want to hide the button or other Views on the click of a button, you can set their visibility to gone programmatically.

Is it possible to include a MapView as an element of another activity?

Just as the title says...I want to include a MapView inside of another activity. For instance, I want the MapView to take up half of the screen, and below that, include some other widgets - text fields, buttons, whatever. I have been tinkering with it, but so far I have been unsuccessful - the map does take up only half the screen, but no widgets show up.
Any clues? Is this possible, or is the Google Map integration strictly using the map as a full screen?
Please post your xml layout!
You are just doing it wrong. :-D
A mapview will work like any other widget. I strongly believe there is a mistake in your layout.
This one will work for instance!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/h1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox
android:text="Satellite"
android:id="#+id/satellite"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<ImageView
android:id="#+id/image"
android:layout_width="75dip"
android:layout_height="75dip"
android:layout_marginRight="6dip"
android:src="#drawable/uoicon" />
</LinearLayout>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0zDdYFYf6Ir2W-NuiHPLAoFjsq0nmqRhPfzjY3A"/>
</LinearLayout>
Just a guess but you're using a LinearLayout to contain the MapView and other widgets but you forgot to set the orientation to vertical? The default for LinearLayout is horizontal.
It came to mind because it's something I've done 2 or 3 times myself. Totally confusing as effectively the other widgets 'disappear' off the right-hand side of the screen. It eventually got engrained in my mind and I always make sure to explicitly specify orientation now when I use LinearLayout.

How to set height for the listview that created dynamically through java code?

I 'm trying to set the height of the listview which has been created through java code dynamically. I'm using 3 listviews(one below another) in a scrollview(to avoid hiding of lists). If i use scroll view, i cannot see all the list items of the listviews.Is there any idea to set height for those 3 list views through java coding in android? Any help is really appreciated and thanks in advance...
Don't put ListViews in ScrollViews! In Detail Information from the developers of Listview is available in the talk World of ListViews
It is possible to make the three ListViews share the space on the Screen by using the layoutWeight parameter.
Make a layout like this (you can also use code for that):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#+id/listView1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"></ListView>
<ListView android:id="#+id/listView2" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"></ListView>
<ListView android:id="#+id/listView3" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1"></ListView>
</LinearLayout>
Here each ListView takes a third of the available space (all weights set to 1).
To set the layoutWeight in code use this line as example:
listview1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

Categories

Resources