I want to load image runtime in my activity but it is load in portait view only.
If I want to load it in landscape it doesn't.
I also do it by both seprate xml for landscape and portrait.
and also try by only one xml.
I draw image like this
result_img.setImageDrawable(getResources().getDrawable(R.drawable.invalid_title));
But it draw in only portait layout.
goto Manifest file and remove android:screenOrientation="potrait" attribute because it affect your app to view only in potrait mode only.if you have remove it you can show in both view. and one more thing is that you havent change any xml file
Related
Integrated MPAndroid Line charts, when screen rotates to landscape I want to only graph view to be shown in full screen and all other things should be hidden. I have restricted orientation to "Portrait", how can I trigger when screen rotates to landscape even though it is restricted.
you can duplicate the XML layout file of your activity, and put it inside folder /res/layout-land if you don't have it create it. Then you can change the visibility to "gone" at the views you don't want to show in landscape mode.
Also don't restrict the orientation to portrait for this activity
I´ve made an app where´s just some text and a background image.
When I tilt my phone my background image gets streched out..
What I want to do is when I tilt the phone I get now background image.
What you need to do is create different layouts for your views in landscape and portrait mode and put the landscape ones in res/layout-land and the portrait ones in res/layout-port. Simply get your current XML file and copy it into both the portrait and landscape stalks and then just change the drawable that is referenced for the background. That way you can have one that fits well for portrait and another that you've edited to fit for landscape views.
you need to provide a different layout for that orientation.
create a layout-landscape folder, and in that layout change the background to the one you want for your landscape layout. besides you can completely customize your landscape orientation that way.
yes you can change the background
for that you have to create another xml file with same name of the xml you are using right now
then copy all the code from your previous xml to this new xml
you have to create this xml inside the land named folder,if that folder dosent exist than crete a folder name land inside your layout folder..
you just have to change one thing in your xml and here you gooo
android:background="#drawable/yournewbackgroundname"
do not change any thing in our old xml
Can we fix the orientation for one imageview in framelayout, and orientation of other children of frame layout be controlled by the sensor?
I want to fix the orientation of image in background and on top of that need to show some reults in textviews. If I fix the activity in landscape then I can't draw the text portrait wise.
You can use separate xml for portrait and landscape mode.
1.you have to create separate folders layout-land, layout-port
2.save the xml in it.
3.Be sure with both have the same name.
You can refer here
Orientation can only be applied on activities,we cannot set the orientation of views.
I have an image view with an image and it looks find when the phone is portrait. When I turn it landscape, it rotates, however, the image isn't centered anymore. How do I go about doing that?
Create a layout-land directory in your res folder. And copy your layout files with landscape orientation. That should do it.
Rather than making a new folder and xml file and all that, I simply did
android:layout_width="match_parent"
on my image view and when I rotate the device, the image stays centered.
I have done my application in portrait configaration but when load my application in to device its coming portraint configaration but I keep in landscape mode missing some controls. So I want to add scroll view to screen when changing the config to landscape. How I can add ScrollView to screen ?
You could define two version of your layout.
"res/layout/your_layout.xml" - this will be used in portrait mode
"res/layout-land/your_layout.xml" - android will use this when in landscape orientation
If you don't want to do to many changes in your layout you can add ScrollView to landscape version of your_layout.xml.
Regards!