I have the following issue.
In an activity which is set up in LANDSCAPE
mode I have a button.This magical button is set on the right side of the activity and at the bottom of the screen from my point of view.
This is how it looks like: http://i52.tinypic.com/n63rmb.png .
This is the xml
file of my activity :
<?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">
<LinearLayout andr开发者_运维问答oid:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"
android:layout_weight="1.0">
<SurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/surface_camera"
/>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="500px">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/btnPhoto"
android:text="Take Photo"
android:layout_gravity="bottom|left"
/>
</LinearLayout>
</LinearLayout>
And this is the animation I do with the button
:
takePhoto = (Button) findViewById(R.id.btnPhoto);
takePhoto.setText(t);
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
ranim.setFillAfter(true);
takePhoto.setAnimation(ranim);
And finally this is res/anim/myanim xml
file:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="-90"
android:pivotX="50%"
android:pivotY="50%"
android:duration="0" />
Now please tell me how to increase the width
of that button, please.Thank you
BTW: I tried this:
Display display=getWindowManager().getDefaultDisplay();
width=display.getWidth();
height=display.getHeight();
takePhoto.setWidth(width);
But there is no change at all!
There is two problem in your code...first one is due to animation...comment your animation code...or change it...I run your code after commenting it out...
//RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
//ranim.setFillAfter(true);
//takePhoto.setAnimation(ranim);
And second problem is layout, try this layout for your R.layout.takephoto
<?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:orientation="horizontal">
<Button android:layout_width="fill_parent"
android:layout_height="45dp" android:id="@+id/btnPhoto" android:text="Take Photo"
android:layout_alignParentBottom="true" />
<SurfaceView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/surface_camera"
android:layout_above="@id/btnPhoto" />
</RelativeLayout>
One suggestion: Try to use RelativeLayout....it will simplify your layout.
精彩评论