AnimateLayoutChanges property disabled alpha property from child element - android-layout

When I'm adding animatedLayoutChanges="true" to my parent Layout the alpha from the child layout doesn't work anymore:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animateLayoutChanges="true"> // <<<<<<<
<LinearLayout
android:id="#+id/my_outofzoom_text_tablet_landscape"
android:layout_width="300dp"
android:layout_marginTop="25dp"
android:layout_centerHorizontal="true"
android:layout_height="100dp"
android:background="#drawable/border_rounded_corner"
android:layout_toRightOf="#id/movable_layout"
android:alpha="0.5" // <<<<<<<
android:visibility="gone"
android:gravity="center"
android:clickable="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffff"
android:layout_margin="5dp"
android:textSize="25dp"
android:text="#string/to_far_away">
</TextView>
</LinearLayout>
Does anybody got an idea why this is so and what can i do ?

I guess animatedLayoutChanges uses AlphaAnimation with keepLastFrame = true, which is editing your pre-determind alpha.
I never did, but maybe you can try to set animation listener and reset your desired alpha in the end. ( be aware animation listener has a bug on samsung devices it may not be called at all )

Related

How to show HereMaps inside an android Linear Layout

Is there anyway to show HereMaps inside a Linear Layout?
This is my layout file and I want to show map in firstMap (LinearLayout).
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.apploft.tabs.MyTabFragment">
<RelativeLayout
android:id="#+id/confirmed"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/firstMap"
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="#color/cardview_shadow_start_color"
android:orientation="horizontal">
<!-- Map Fragment embedded with the map object -->
</LinearLayout>
</FrameLayout>
By adding maoview inside LinearLayout and then calling
<com.here.android.mpa.mapping.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible"/>
in the fragment
MapView mapColView = (MapView) colTabView.findViewById(R.id.mapview);
map = new com.here.android.mpa.mapping.Map();
map.setCenter(new GeoCoordinate(51.509865, -0.118092, 0.0), com.here.android.mpa.mapping.Map.Animation.NONE);
// Set the zoom level to the average between min and max
map.setZoomLevel((map.getMaxZoomLevel() + map.getMinZoomLevel()) / 2);
mapColView.setMap(map);
Also test/check onResume() onPause().
Use a MapView instead of a MapFragment in this case. The documentation is linked here for starter and here for premium.

Android nested layout with layout_weight

I would like to create left and right reserved spaces (LinearLayout) on screen which give me felexiblitiy to ensure my UI is working in different size of screen as I want,
and in middle create a TableLayout to apply views and contorls, everything good great
except TableRow - android:layout_width is became zero, TableLayout width is not really zero however I had to put android:layout_width="0dp" for TableLayout to force android:layout_weight="4" working
how can I tell TableRow to take actual parnt(TableLayout) width
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="#+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="#+id/widget33"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
</LinearLayout>
<TableLayout
android:id="#+id/widget34"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="4">
<TableRow
android:id="#+id/widget64"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/widget72"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I m here" />
</TableRow>
</TableLayout>
<LinearLayout
android:id="#+id/widget35"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
</LinearLayout>

ViewSwitcher with EditText leaves extra padding

I'm using a ViewSwitcher to allow switching from a TextView to an EditText element. What I've noticed is that the EditText element generates extra padding at the bottom of the view (i.e. if I remove the EditText everything looks as expected, but adding it, even when visibility is set to gone, generates extra space at the bottom). What's causing this and how should it be resolved?
<ViewSwitcher
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/IngredientsLineSwitcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/IngredientsLineText"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="0dip"
android:paddingLeft="10dip"
android:paddingTop="0dip"
android:text=""
android:textColor="#color/black"
android:textSize="#dimen/recipe_label_font_size" />
<EditText
android:id="#+id/IngredientsLineEdit"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingBottom="0dip"
android:paddingLeft="10dip"
android:paddingTop="0dip"
android:text=""
android:visibility="gone"
android:textColor="#color/black"
android:textSize="#dimen/recipe_label_font_size" />
</ViewSwitcher>
You should put a RelativeLayout around the TextView or EditText to control their positioning.
-----
android:layout_height="match_parent" >
mlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/IngredientsLineSwitcher"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/IngredientsLineText"
android:layout_height="match_parent"
android:layout_width="match_parent"
----
<EditText
android:id="#+id/IngredientsLineEdit"
android:layout_height="match_parent"
android:layout_width="match_parent"
-----
Change from fill_parent to match_parent in all Views.

How to display a SeekBar correctly? (layout_weight)

I`m trying to create the following layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<SeekBar
android:id="#+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
I`d like to give the 80% of the parent layout to the textView1 and textView2, wrap the SeekBar as much as possible and the rest of the free space give to the textView3.
I`ve tried to:
use layout_weight attributes (respectively - 4, 4, 1, 1) but the last
view overlaps the SeekBar
use layout-weight only with textView1 and textView2, set SeekBar`s height to "wrap_content" and set "match_parent" for the last view
And now I have no more ideas. Have you ever had such a problem?
well to create this layout I would try :
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="4" >
</TextView>
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="4" >
</TextView>
<SeekBar
android:id="#+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
</TextView>
make change on weights tu adjust sizes.
let the seek bar to wrap content, give weight on other views.
tell me if that helps.

LinearLayout won't fill parent; instead if fits to the smallest width view in it

I have a view that looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingBottom="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout android:id="#+id/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView android:id="#+id/title_icon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:src="#drawable/title_icon" />
<LinearLayout android:id="#+id/title_layout"
android:layout_toRightOf="#id/title_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<TextView android:id="#+id/title_text"
android:text="#string/activity_complete"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="15dp"
android:textSize="12dp"
android:textStyle="bold"/>
</LinearLayout>
<TextView android:id="#+id/status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textSize="8dp" />
</RelativeLayout>
<TextView android:id="#+id/message_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:paddingLeft="15dp"
android:textSize="10dp"/>
<ImageView android:id="#+id/main_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey"
android:padding="5dp"/>
</LinearLayout>
My problem is that the main LinearLayout view doesn't match_parent or fill_parent. It seems to want to only contain the smallest item within it. In my case it will result in a width the same as main_image, cutting off the content of everything else. However, if I set main_image to visibility.gone then it will match the width of message_text.
I've tried removing everything except main_image and the main LinearLayout still only fits the image width.
The other thing is that this layout is inflated into another LinearLayout which is set to fill_parent.
Wrapping the ImageView in another LinearLayout fixed the issue.
I just had this problem -- adding a LinearLayout configured to "match_parent" to another LinearLayout, but the inner layout did not fill the outer one properly.
Initially I was doing this to add the layout:
LinearLayout inner = getLayoutInflater().inflate(R.layout.inner, null);
outer.addView(inner, 0);
After a few minutes of exasperation I tried this instead:
LinearLayout inner = getLayoutInflater().inflate(R.layout.inner, outer);
And inner matched the outer parent width and height.

Resources