Android layout designer
New to IntelliJ, check kb but unable to find answer. Using 12.1.3
I have tried to use the designer for assistance with an Android layout. While the end result seems ok, I have question about what this designer is showing and why. Specifically, I have a tablelayout, the first tablerow of which has three cells. I've set the layout:width to 0dp and have used layout:weight to apportion the column sizes. However, in the design window there are two unexplained (or at least confusing to me) boxes drawn when selecting the first cell of the table row. One is red, the other is blue. Both are much narrower than that cell and in the case of the blue box, the height of the entire layout.
However, when selecting the second or third cell, the red box appears to be the correct (or at least expected) dimension around that layout element. The same can be said of other portions of the layout (not visible in attachment) except again, first cell in a table row.is wrong size.
I've included image. What is going on? Is it a problem with my layout or the designer? I've run on a physical device and the layout seems to work ok.
Thanks for your help.
Attachment(s):
whatisthis.gif
请先登录再写评论。
Hello,
> I have a tablelayout, the first tablerow of which has three cells.
Please show your layout xml file.
> I've run on a physical device and the layout seems to work ok.
Try run on emulator.
Designer work (render layout to image) over Android SDK lib.
Here is the main.xml layout: http://pastebin.com/WznDj1Vp
I see another result.
Please try last release/EAP/Android Studio and last SDK.
Attachment(s):
Untitled.png
Hi - I am using the community 12.1.3 and just did update check and it says I have the latest version. Likewise Android SDK. I did not want to install Android studio (that is the Google fork right?) as I also plan to do some other development work. Also, my understanding is that the latest alpha of 13 which includes the functionality of the former has had some issues with the latest SDK and I generally prefer to stick to beta or better.
I'm assuming you are using one of those versions so perhaps this is a problem with 12.1.3 which will be/is resolved in the new version?
I've played around with it a bit just taking this small layout below. It is fine if a) stretchColumns * is used and b) all columns are equal weight. If not, I again end up with the frame around the first cell/column not being correct - without stretchColumns the frame is too small, with stretchColumn but differing column sizes at least one of the columns (usually first or second) have a too large frame.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:showDividers="end"
android:stretchColumns="*">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/tv_u_price"
android:textSize="13sp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:typeface="monospace"
android:textStyle="normal"
android:layout_gravity="top"
android:gravity="center_vertical|left"
android:layout_weight="0.2">
</TextView>
<TextView
android:id="@+id/tv_u_symbol"
android:textSize="13sp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:typeface="monospace"
android:textStyle="normal"
android:layout_gravity="top"
android:gravity="center_vertical|left"
android:layout_weight="0.2">
</TextView>
<TextView
android:id="@+id/tv_opt_delta"
android:text="@string/opt_delta"
android:textSize="12sp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:typeface="monospace"
android:textStyle="normal"
android:layout_gravity="top"
android:gravity="center_vertical|left"
android:layout_weight="0.35">
</TextView>
<TextView
android:id="@+id/tv_opt_gamma"
android:text="@string/opt_gamma"
android:textSize="12sp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:typeface="monospace"
android:textStyle="normal"
android:layout_gravity="top"
android:gravity="center_vertical|left"
android:layout_weight="0.25">
</TextView>
</TableRow>
</TableLayout>
Bumping this back up. Been out a few days and now also have new devel machine. I've installed the 130.754 and still have the same issues with this layout. The xml is here and is best viewed in landscape mode, say for N7. Two things I am having a problem with:
1) click on the edit text box. A blue border appears and extends past the expected 1/4 width of the screen. Clicking on the button next to it and the linear layout fields of that same tablerow, a border appears and is the expected size (1/4 and 1/2 the screen width).
2) Clicking on listviewLeft and listviewRight again displays blue borders of the incorrect size (should be 50% of width).
That said, the layout appears to function correctly on both a tablet device and an emulator of N7. In looking at the size of the border it displays around the edittext box, it appears to wish to use 1/3 of the screen. Likewise, for the listviews Right/Left, it again appears to want to use 1/3 of the screen width for the border.
Further: If the * is removed from the strechColumns field of tableLayout1
1) clicking on the edittext box now shows a blue border of 0 or 1 pixel wide, it is impossible to tell exactly,
2) The previously incorrect blue borders as mentioned in point #2 above are now displayed correctly., 50% each.
So... is this a problem with my xml layout or is it a problem with the layout designer in the IDE? I'm pretty new to Android and IJ so perhaps it is just something stupid (and unobvious to me). But as the layout does appear to function properly, I think it may be IJ problem?
TIA
Have been having the same problem. can't figure out what it is? Probably the layout. Going to show it to a fellow developer to get it sorted. Let's see
_____________
agile testing
Thanks, please update the thread if you find something out. Given that the layout appears to work ok on my hardware and also in the emulator, I'm thinking its something with the layout designer but I'm an android novice so maybe not. Cheers.