Issue
I'm trying to style buttons to look like those I ask about in Android Full Width ICS style Minimalist Bottom ButtonsViews.
I've succeeded, with the following xml for anyone interested:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:divider="@android:drawable/divider_horizontal_dark"
android:gravity="bottom"
android:orientation="vertical"
android:paddingTop="16dip"
android:showDividers="beginning|end" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:measureWithLargestChild="true"
android:orientation="horizontal"
android:divider="@android:drawable/divider_horizontal_dark"
android:showDividers="middle" >
<Button
android:id="@+id/cancel_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:maxLines="2"
android:text="@string/cancel_button" />
<Button
android:id="@+id/login_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:filterTouchesWhenObscured="true"
android:maxLines="2"
android:text="@string/login_button" />
</LinearLayout>
</LinearLayout>
One question though. The eclipse content assist has no idea what's happening with the following resource resolution:
style="?android:attr/buttonBarButtonStyle"
I'm familiar with the typical resolution (which eclipse's content assist is aware of)
style=@android/style/...
...but I'm not clear on the difference between the two. It seems like some style attributes appear in one but not the other. For instance, the following doesn't resolve to anything:
style=@android:attr/buttonBarStyle
and neither does this:
style="@android:style/buttonBarStyle
So I guess two questions here:
- Why the difference in resource referencing syntax?
- Why the confusing miscategorization of styles in under an attr category.
- What is the attr category even used for again?
Thanks!
Solution
From another answer on SO (paraphrased here):
Using a question mark in front of an ID means that you want to access a style attribute that's defined in a style theme, rather than hardcoding the attribute.
Think of it as dereferencing a theme attribute to fetch the resource it points to rather than referring to the attribute itself.
Answered By - Barak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.