I want to create sliding drawer in android which should be placed on top of the activity and should be open from top to bottom like android notification panel. How to achieve this?
The default SlidingDrawer class doesn't allow this. You can use the Panel class from here to get something very similar though OR set the rotation of 180ยบ for the SlidingDrawer, the content and the handle. Note : android:rotation is support on API > Level 11
http://www.ohloh.net/p/android-misc-widgets
https://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/SlidingDrawer-Topdown
Reference
If you want to have sliding drawer from top to bottom then just copy pase this code in your project, it is 100% working code.
main.xml
<?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="#d3d3d3"
>
<SlidingDrawer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/slidingDrawer"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:content="#+id/content"
android:gravity="center_horizontal"
android:handle="#+id/handle"
android:orientation="vertical"
android:rotation="180" >
<LinearLayout
android:id="#+id/handle"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:gravity="right"
android:background="#+drawable/drawer_bk"
>
<ImageView
android:id="#+id/imageView"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#+drawable/drawer1" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="45dp" >
<RelativeLayout
android:id="#+id/rel1"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:rotation="180" >
<ImageView
android:id="#+id/ImageView04"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="visit"
android:src="#drawable/visit_icon" />
<ImageView
android:id="#+id/ImageView03"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_marginRight="35dp"
android:layout_toLeftOf="#+id/ImageView04"
android:onClick="contact_us"
android:src="#drawable/contact_icon" />
<ImageView
android:id="#+id/ImageView02"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_toRightOf="#+id/ImageView04"
android:onClick="logout"
android:src="#drawable/singout_icon" />
</RelativeLayout>
</RelativeLayout>
</SlidingDrawer>
MainActivity.java
public class MainActivity extends Activity
{
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 4000;
Button slideButton,b1, b2,b3,b4;
SlidingDrawer slidingDrawer;
#SuppressWarnings("deprecation")
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//slideButton = (Button) findViewById(R.id.slideButton);
slidingDrawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
#Override
public void onDrawerOpened()
{
// slideButton.setBackgroundResource(R.drawable.down_arrow_icon);
slidingDrawer.setBackgroundResource(R.drawable.hd_img_1);
}
});
slidingDrawer.setOnDrawerCloseListener(new OnDrawerCloseListener()
{
#Override
public void onDrawerClosed()
{
// slideButton.setBackgroundResource(R.drawable.upwar_arrow_icon);
slidingDrawer.setBackgroundColor(Color.TRANSPARENT);
}
});
}
}
Related
I am trying to implement a panel in a fragment that can expand on button click from the right side of the screen. I can't use the navigation drawer, because I already have navigation drawers from both left and right sides.
The idea is to achieve something like that:
I was almost able to do it with the SlidingDrawer widget (it's deprecated..), the only problem is that I don't know how to make the LinearLayout to appear in the middle and then to shift when the button to expand the SlidingDrawer is clicked.
I have the following code:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button handle = (Button) findViewById(R.id.handle);
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
drawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
#Override
public void onDrawerOpened() {
}
});
drawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
#Override
public void onDrawerClosed() {
}
});
}
}
And the XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
<LinearLayout
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp"
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
You can edit your XML like this
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:id="#+id/left" // this is your linear layout
android:layout_width="match_parent" // that you want to shift left
android:layout_height="match_parent"
android:layout_toLeftOf="#+id/right" // apply this property due to
android:layout_alignParentLeft="true" //which if the width of sliding menu
android:gravity="center" //increase it will automatically compressed
android:background="#aa00aa"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
<LinearLayout
android:id="#+id/right"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:background="#0000aa"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp" // you can check by increasing or decreasing the with of this slidingdrawer
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TEST" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
apart from this if set any layout to the right of your linear layout which is initially GONE and as you click on the button its visibility changed to INVISIBLE/VISIBLE so it will shift the linear layout to left. Hope that helps!
If you want a little exemple here is my solution: (I don't know if Avani Nagar's solution works or not):
TextView res;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView img = (TextView)findViewById(R.id.second);
res = (TextView)findViewById(R.id.first);
img.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
img.setX(img.getX() - 5);
changew(img.getX());
}
});
}
private void changew(float w){
res.getLayoutParams().width = (int)(res.getX() +w);
res.requestLayout();
res.invalidate();
}
The xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<TextView
android:layout_toRightOf="#+id/first"
android:text="bonjourrrrrr"
android:id="#+id/second"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#android:color/holo_red_dark" />
<TextView
android:text="salutttttttt"
android:id="#id/first"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="#android:color/holo_green_light" />
</RelativeLayout>
I managed to do it, it actually wasn't so difficult, but it's a little tricky. Here is the solution:
The xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/topLayout"
tools:context="com.test.slidingdrawertest.slidingdrawertest.MainActivity">
<LinearLayout
android:id="#+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST" />
</LinearLayout>
<LinearLayout
android:layout_alignParentEnd="true"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<SlidingDrawer
android:id="#+id/slidingDrawer"
android:layout_width="200dp"
android:layout_height="400dp"
android:layout_marginTop="100dp"
android:layout_gravity="end"
android:content="#+id/content"
android:handle="#+id/handle"
android:orientation="horizontal">
<Button
android:id="#+id/handle"
style="?android:attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Expand" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST TEST TESTT" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>
The code in MainActivity.java:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button handle = (Button) findViewById(R.id.handle);
SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.slidingDrawer);
final View k = findViewById(R.id.mainLayout);
drawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
#Override
public void onDrawerOpened() {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
k.setLayoutParams(params);
}
});
drawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
#Override
public void onDrawerClosed() {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
k.setLayoutParams(params);
}
});
}
}
And the explanation: I had to give main main layout an id (in XML) and then find it in the code behind, then I had to apply new parameters to it when the drawer opens or closes. Basically, we need to find the parent layout and set the parameters to it.
Now the LinearLayout is able to shift it's position on drawer open, and it goes back to it's original position on drawer close. Next step is to make this process with an animation, so it's smooth and doesn't just jump back and forth to the new positions.
I am facing a weird issue with dialog fragment , its not showing the complete proper layout. I have checked on Moto G and Nexus 5 both show same result. Any help would be appreciated.
Graphical layout screen shot is:
Device screen shot is:
Here is the activity code:
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showGridTutorial();
}
public void showGridTutorial() {
DialogFragment fragment = new GridTutorial();
fragment.show(getSupportFragmentManager(), "grid_tutorial");
}
public static class GridTutorial extends DialogFragment {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// TODO Auto-generated method stub
Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_layout);
return dialog;
}
}
}
XML layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#eeede9"
>
<View
android:id="#+id/vertical"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_above="#+id/btnGotIt"
android:background="#e8e7e4"
/>
<View
android:id="#+id/horizontal"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:background="#e8e7e4" />
<Button
android:id="#+id/btnGotIt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Got it"
android:gravity="center"
android:background="#android:color/black"
android:textColor="#eeede9"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/vertical"
android:layout_above="#+id/horizontal"
android:src="#drawable/showease3" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/vertical"
android:layout_above="#+id/horizontal"
android:src="#drawable/showdase" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/horizontal"
android:layout_toLeftOf="#+id/vertical"
android:layout_above="#+id/btnGotIt"
android:src="#drawable/showcase" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/horizontal"
android:layout_toRightOf="#+id/vertical"
android:layout_above="#+id/btnGotIt"
android:src="#drawable/showdase" />
</RelativeLayout>
Try to change RelativeLayout width and height to wrap_content.
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#eeede9"
Hope this will help you!
You need to choose a minimum width and minimum height for your layout. Something like :
android:minWidth="600dp"
android:minHeight="800dp"
Just try playing with the right values.
May be it is so easy but do not know i have tried so much but it's not working :(
I have layout like this way
And i have following java code
public class MainActivity extends FragmentActivity{
private ImageView ivMainMenu;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ivMainMenu = (ImageView) findViewById(R.id.ivMainMenu);
ivMainMenu.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
System.out.println("showSlider clicked");
}
});
}
i have tried
android:clickable="true"
but still not working
below is my xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/rlMainHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_bg"
android:orientation="vertical" >
<TextView
android:id="#+id/tvHeaderText"
style="#style/header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<TextView
android:id="#+id/txtScore"
style="#style/black_large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="#dimen/extra_small"
android:background="#drawable/keyboard_btn"
android:padding="#dimen/extra_small"
android:text="#string/finish"
android:textColor="#color/dark_text_color"
android:textStyle="bold"
android:visibility="gone" />
<ImageView
android:id="#+id/ivMainMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:clickable="true"
android:src="#drawable/menu" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/rlMainHeader"
android:background="#color/main_bg"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/flMain"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<LinearLayout
android:id="#+id/llMainSlider"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:visibility="visible" >
<include
android:layout_width="wrap_content"
android:layout_height="match_parent"
layout="#layout/slider" />
<LinearLayout
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#color/dark_text_color"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</RelativeLayout>
in my logcat i am getting following message whenever i click on imageview
04-27 11:09:42.996: V/Provider/Settings(1018): from settings cache , name = sound_effects_enabled , value = 0
also i want to let you know that if i load any fragment in flMain, in that fragment all event is working fine but not on main layout :( also in llMainSlider noting was happening :(
Why don't you try declaring the event on the XML?
It is as simple as this
android:id="#+id/ivMainMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:onClick="myNewMethod" <!--add this extra line!--->
android:src="#drawable/menu" />
and simply on your Main activity add the myNewMethod as am extra function like this
public class MainActivity extends FragmentActivity{
private ImageView ivMainMenu;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void myNewMethod(View v) {
System.out.println("showSlider clicked");
}
Good Luck ;)
I've created an Android sliding drawer but when it is dismissed it is completely hidden. The behavior that I'm looking for is to have the first row of the drawer visible at all times. If this is possible what is the best way to attempt this?
This works for me:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button 1" />
<SlidingDrawer
android:id="#+id/slidingDrawer1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/button1"
android:content="#+id/content"
android:handle="#+id/handle" >
<Button
android:id="#+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Handle" />
<ScrollView
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/content1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical" >
<Button
android:id="#+id/button1a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 1" />
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button 2" />
</LinearLayout>
</ScrollView>
</SlidingDrawer>
</RelativeLayout>
And in main activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
actionsSlider = (SlidingDrawer) findViewById(R.id.slidingDrawer1);
actionsSlider.setOnDrawerCloseListener(new OnDrawerCloseListener() {
public void onDrawerClosed() {
firstButton = (Button) findViewById(R.id.button1);
firstButton.setVisibility(View.VISIBLE);
}
});
actionsSlider.setOnDrawerScrollListener(new OnDrawerScrollListener() {
public void onScrollStarted() {
if (!actionsSlider.isOpened()) {
findViewById(R.id.button1).setVisibility(View.GONE);
firstButton = (Button) findViewById(R.id.button1a);
}
}
#Override
public void onScrollEnded() {
}
});
}
I am currently working on a application .when i installed my_app in android mobile while rotating in horizontal view my buttons are missing,please help!! Thanks in advance
My java coding is:
public class Draw extends Activity {
ImageView iv1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final DrawView drawView = new DrawView(this);
setContentView(R.layout.draw);
FrameLayout frm_layout=(FrameLayout) findViewById(R.id.main_frame);
iv1=(ImageView) findViewById(R.id.imageView1);
frm_layout.addView(drawView);
Intent myIntent = getIntent(); // this is just for example purpose
String test=myIntent.getExtras().getString("guided");
if(test.equals("1"))
{
iv1.setImageResource(R.drawable.untitled);
iv1.setAlpha(100);
}
else
{
//iv1.setImageResource(null);
}
//Toast.makeText(getApplicationContext(), test.toString(), 2000).show();
Button btn_undo=(Button) findViewById(R.id.button1);
btn_undo.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
drawView.onClickUndo();
}
});
Button btn_redo=(Button) findViewById(R.id.button2);
btn_redo.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
drawView.onClickRedo();
}
});
}
}
My XML coding is below:
<?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="#android:color/white" >
<FrameLayout
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="472dp"
android:background="#android:color/white" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Redo" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Undo" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Save" />
</RelativeLayout>
</LinearLayout>
Just Copy and Past in you xml file, it wil run completely. I have tested.
<?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="#android:color/white" >
<FrameLayout
android:id="#+id/main_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white" android:layout_weight="0.1">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.9" android:layout_gravity="bottom" android:layout_marginTop="-10dp">
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Redo" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Undo" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Save" />
</RelativeLayout>
</LinearLayout>
Hope this is what you want.
do one thing make a folder named Layout-land in res folder , in which put your xml file. now you can design your xml in horizontal mode . do whatever changes you want in that file and check :
otw put a scroll bar in whole layout and then check :) good luck