why are my buttons not fitting properly? - android

In landscape mode they properly stretch to fit the width..but in portrait the Exit button is extending too far to the right.
layout code: http://pastebin.com/KZVCdVJw

The reason why it wasnt properly fitting the screen was due to the orientation of the LinearLayout it was in. By changing the orientation from horizontal to vertical it solved the problem.

Related

How do I prevent my button and text views from overlapping whenever I tilt the screen?

How can I do this in portrait and landscape view?
I tried to attach the constraints below each other respectively but nothing worked.

Android - How to make a landscape layout on a fixed portrait screen?

My application's orientation is fixed to portrait due to some functionalities that always in action.
I need to add to the main activity a fragment with a landscape orientation, so it's layout should be portrait, but rotated 90 degrees.
My problem is that a TextView won't fit the screen because it's width is longer than the screen's width. Also, rotating it (or anything else) won't work properly because the rotation is being done after it's being located.
Is there any library that can handle such thing? Or what can I do to handle that problem?

Problems with backgrounds and layers (Android Studio)

I have a problem with the background of a View in this project.
There is one View with a transparent layer, which is not always displayed... It looks like if, in some cases, the height of this View was automatically set to 0, as I can see in the preview of the activity that contains the View. The code of this element is as follows:
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:alpha="0.5"
android:background="#drawable/background_layers" />
The main view group in this activity is a ScrollView. If the whole layout is displayed and is visible on the screen (so you don't need to scroll down) everything works fine (look at the transparent layer, which is the topic of this question):
But if the screen density is low, or if the device is in portrait orientation, and I must use the scroll because the full layout is not displayed at the same time... the previous View is not shown, the transparent layer is not visible :(
It happens when the app is running and also in Android Studio, in the preview screen, as I said. Here is an example with vertical orientation and low screen density, as seen on the preview tab of the activity in Android Studio:
Any idea to fix this isue?
Thanks in advance.
David.
I think I found the problem with your layout. The transparent_background view sometimes takes height 0 because its height is match_parent and its parent (the main_relative_layout view) has its height set as wrap_content. You should set the transparent_background dimensions relatively to another view, the LinearLayout that wraps the content maybe, using android:layout_alignTop, android:layout_alignBottom, android:layout_alignLeft and android:layout_alignRight attributes. You may need to remove the LinearLayout margin and use padding instead to align the transparent_background view correctly, let me know if you need some help.

How can we fix the orientation for one view?

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.

In android, when changing the orientation, text in textview is not getting wrapped

im locking the screen orientation by specifying android:configChanges="orientation|keyboardHidden"
im setting a text to a textview and adding it to a custom viewgroup. when changing the orientation im changing the width and height of the textview.
when Im running the application, if I have the screen in landscape, the text is in single line and if in portrait, the text is in two lines. so there is enough space to display the text in both orientations.
But when I change the orientation from Landscape to portrait, the text is not wrapping and I can see only a part. If I change the orientation from portrait to landscape, the text was getting displayed in two lines and not getting stretched.
Whether I want to do anything in onConfigurationChanged() Method????
Please help me out. Thank you.

Categories

Resources