I've discovered a long time ago that when it comes to Android, not 
everything works as it should :)


On Wednesday, June 5, 2013 1:28:18 PM UTC+3, Dusk Jockeys Android Apps 
wrote:
>
> Thanks, Piren.
>  
>
> Unfortunately none of that helps, as sometimes you really need things to 
> work as they should. In my case it is A and B that are fixed, and C has to 
> depend on them. 
>
> I resorted to messing about with Font Metrics, working out manual 
> displacements based on font size, which is pretty messy. Honestly I don’t 
> see why this should be a dependency issue, when 
>
> layout_alignBottom which does exactly the same thing (but without the 
> vertical offset) works fine, C happily sits above B if B is aligned to A's 
> bottom, rather than its baseline.
>
>  
>
> However, that led me to find a little quirk, if you align B to A using 
> simultaneous layout_alignBottom and  layout_alignBaseline flags, then C’s 
> positioning now works, it happily sits above B exactly as if just 
> layout_alignBottom was being used, although B is still aligned to A’s 
> baseline. The caveat is that C’s positioning is sligthty lower than normal; 
> it behaves as if the B is aligned to A’s bottom, then C is positioned, and 
> then B is realigned to A’s baseline, without C changing position. However I 
> can get round that with some margin offsets, and at least it can be done 
> via XML.
>  
>
> On Tuesday, May 21, 2013 11:37:51 PM UTC+8, Piren wrote:
>
>> I'm not too sure why this is happening... i'm guess that alignBaseline 
>> affects measuring differently and causes a cyclic dependency (Romain?)
>>
>> Try changing the relationships so you'll define A and B Below C instead, 
>> since C has a constant location anyhow.
>>
>> Also if your View hierarchy isnt too complex and wouldn't need to be 
>> refreshed too often, you can let yourself use more ViewGroups (use a 
>> linearlayout to divide the top and the bottom views)... Although that 
>> increases the amount of views you have and makes the rendering tree bigger, 
>> it will be easier for you to read the XML and understand the behavior and 
>> also prevent this weird behavior. 
>>
>> On Tuesday, May 21, 2013 5:49:20 PM UTC+3, Dusk Jockeys Android Apps 
>> wrote:
>>>
>>> I have a layout issue which it seems should be simple to do in a 
>>> RelativeLayout.
>>>  
>>> I have a view A, and a view B which is aligned to A's baseline, and 
>>> aligned to the right of the parent. B appears correctly.
>>>  
>>> Then I want a view C to be directly above B, and also aligned to the 
>>> right of the parent. However, C never appears. 
>>>  
>>> However, if I change B to be aligned to the *bottom* of A, as 
>>> opposed to its *baseline*, then C appears. 
>>>  
>>> So it seems that layout_above doesn't like to act upon something that 
>>> references another view via layout_alignBaseline, but is fine acting upon 
>>> something that references another View via layout_alignBottom.
>>>  
>>> Can anyone shed any light upon this? It seems like it is a common 
>>> scenario that should work. See the following.
>>>  
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <RelativeLayout xmlns:android="
>>> http://schemas.android.com/apk/res/android";
>>>     android:id="@+id/mainlayout"
>>>     android:layout_width="fill_parent"
>>>     android:layout_height="fill_parent"
>>>     android:orientation="vertical" >
>>>     <TextView
>>>         android:id="@+id/A"
>>>         android:layout_width="wrap_content"
>>>         android:layout_height="wrap_content"
>>>         android:text="A"
>>>         android:textColor="@android:color/white"
>>>         android:textSize="182dp" />
>>>     <TextView
>>>         android:id="@+id/B"
>>>         android:layout_width="wrap_content"
>>>         android:layout_height="wrap_content"
>>>         android:layout_alignBaseline="@id/A"
>>>         android:layout_alignParentRight="true"
>>>         android:text="B"
>>>         android:textColor="@android:color/white"
>>>         android:textSize="26dp" />
>>>     <TextView
>>>         android:id="@+id/C"
>>>         android:layout_width="wrap_content"
>>>         android:layout_height="wrap_content"
>>>          android:layout_alignParentRight="true"
>>>         android:layout_above="@id/B"
>>>         android:text="C never appears!"
>>>         android:textColor="@android:color/white"
>>>         android:textSize="20dp" />
>>> </RelativeLayout>
>>>  
>>> Regards,
>>> James
>>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to