Android 3.2 Strange view issues - android

I'm new to Android development, and was testing my application in the 3.2 simulator to ensure that everything scales correctly on a tablet. The view consists of a ListView in a TabBar, and I am experiencing strange issues with misalignment of the UI (See link). This is not present on any other OS version (2.1 - 4.0) on any of the phone screen sizes.
The ListView items consist of a custom layout that uses a LinearLayout with a background drawable and two textviews for the title and subtitle.
XML Render (10.1in WXGA Tab):
Has anybody got any ideas?
EDIT:
Fixed the issue. I had disabled rotation on my TabBar views in my manifest, by removing this line of code in the XML the list renders as desired. Thanks for all those who contributed.

you can choose to load different layouts,values,and other resources as per device,locale simply changing the folders name by adding specific values,in your case use something like layout-hdpi ,layout-xhdpi

Related

android studio issue: complex Layout is not showing in design view but just as XML

I have a somewhat complex layout.xml file (353 xml lines, 16kb) with multiple nested constraint layouts. This particular xml file is only showing a blank white screen in the design tab but works well when I run it on device and emulator. I have other smaller layout files which show the design normally on android studio but it seems that there is a bug with viewing larger xml files.
Is this a known issue? I tried refreshing layout and removing android studio cache but nothing seems to work. any ideas?
I do not think it has anything to do with the code since it runs normally on device and I am not sure posting the whole xml file on SO is a good idea.
update
What I realised is that all the elements in the layout seem to be 'invisible' at the top left corner since when I hover over them the pointer turns into a hand and when I click , certain elements get highlighted in the component tree. This is a screenshot of what I am seeing:
I added android:visibility="gone" which is vital to my app. Little did I know that it also applies to the design view which I find to be really useless. I want the visibility to be gone during runtime, not on a platform where I am supposed to be tweaking the design of the UI. This is ridiculous to me.
Does anyone know If I can keep visibility="gone" but still see the design in the design view of the layout?
You can use tools:visibility="visible" for designing purposes.
It has zero effect on the view in real use.
Don't forget to keep your android:visibility="gone".
In general, use tools attributes whenever you'd like to manipulate a preview in the designer while keeping your view attributes valid for real use.
Edit:
Keep in mind that there is a huge difference between invisible and gone. More about that

Difference between creating a tablet layout variation and creating a folder for tablet layout

Good day, I would like to ask what's the difference between creating a tablet layout variation and creating a folder for layouts (like: "res/layout-w600dp/" )?
I'm so sorry I'm new in making android app for small (cellular phones/android phones) together with large(tablets) devices.
Can anyone help me, please? I'm really having a trouble on what to do to have layout for tablets. I don't know if the layout for tablets will be automatically displayed when app is run on tablet or I have to put some code in the java part. I've read some documentations but I can't fully understand it. sorry.
Thank you for your help.
If you have two layout files:
res/layout/
activity_main.xml
res/layout-sw600dp/
activity_main.xml
And you have an activity that calls setContentView(R.layout.activity_main), you don't have to do anything else: the first version will be loaded on phones and the second will be loaded on tablets.
If each layout file has views with the same ids (maybe they're just arranged or sized differently), then you can just do whatever logic you want and it will work with both.
Normally, though, the tablet file will include views that the phone version does not. In that case, you should check to see if those views exist before trying to use them. Imagine that the tablet version has a view android:id="#+id/right_panel" and the phone version does not. You might write:
View rightPanel = findViewById(R.id.right_panel);
if (rightPanel != null) {
// do something for tablets
}

Android: two previews of the layout for different devices

Hy,
I know I can launch my app on multiple devices at the same time but is there a way to view two previews of the layout for different devices at the same time without having to launch the avds?
Thanks
In Android studio 2.2 once you have opened your layout file, you can preview the layout for different devices like that :
Yes, there is a way.
Right-click on the activity_main.xml tab, and from the pop-up menu select split-vertically or split-horizontally.
This will create a second xml tab that can use a different screen for design/text. This can be repeated for more tabs, and the tabs can be "torn off" to float separately.

RatingBar deforms my layout in Android 2.3

This is how an item of my ListView in my app looks in Android 4.4 (real device):
And this is how the same activity in the same app looks in Android 2.3 (real device, too):
As you can see, I am using a custom layout for the rating bar, which deforms the activity in Android 2.3 with this horrible vertical bars. Can someone tell me why is this happening?
Set correct android:minHeight and android:maxHeight values for your stars style. This happens because of different parent styles on different platforms.

Android layout render without compiling

I'm new to developing with Android, and the biggest new thing is the way the UI is rendered (relative to other views instead of absolute locations and sizes). As a result, I've been experimenting a lot with layouts, and find myself changing 1 view or even just 1 property of a view, then having to recompile and launch it back into the emulator to see the result. Is there a tool that quickly (or at least quicker) shows what a UI looks like give a layout xml file?
You can look at http://www.droiddraw.org/ but it is not perfect.
You can use Eclipse with Android Development Tools, when opening a layout file you get a preview of what looks like. Besides, ADT provides some nice features for developing and debugging in the Android platform.
When you're in the XML view, simply click the "Layout" tab on the bottom, and you'll be taken to a visual representation of your layout:
Like so:
There are some limitations for sure (e.g. text shadowing, for one, will not be depicted in this view), but it's a good way to get a general idea of how your layout is working.
Versions 2.x and higher of Android Studio render the XML in real-time in the Preview pane of the IDE and it even juxtaposes the XML and outline views side by side.

Categories

Resources