我想扩展Android的小按钮风格.我可以内联:
<Button android:id="@+id/myButton"
style="?android:attr/buttonStyleSmall"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="10dp"
android:text="Click Here"/>
Run Code Online (Sandbox Code Playgroud)
但为了可重用性,我想将这些样式转换为自定义样式.如何将buttonStyleSmall(或Widget.Button.Small?)作为父项添加到样式中?在我的自定义样式XML中这样的东西:
<style name="RightLink" parent="?android:attr/buttonStyleSmall">
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_gravity">right</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingRight">2dp</item>
<item name="android:textSize">10dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
使用该样式的按钮声明:
<Button android:id="@+id/myButton"
style="@style/RightLink"
android:text="Click Here"/>
Run Code Online (Sandbox Code Playgroud)
编辑
使用下面Lukas描述的正确语法(@android:attr/buttonStyleSmall用作父母),我仍然看到两者之间的区别:
使用buttonStyleSmall作为样式和内联样式的按钮:

使用buttonStyleSmall作为父级的自定义样式:

我错过了什么?
我是以编程方式创建具有不同字符串的StaticLayouts,然后将每个字符串应用于一个位图,然后将其添加到画布中.SL在被我在SL构造函数中定义的固定高度切断之前最多显示两行.但是没有省略号表示文本比显示的长.
从http://developer.android.com/reference/android/text/StaticLayout.html我看到第三个构造函数在结尾处有截断参数:
StaticLayout(CharSequence source, int bufstart, int bufend, TextPaint paint, int outerwidth, Layout.Alignment align, float spacingmult, float spacingadd, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth)
Run Code Online (Sandbox Code Playgroud)
我知道,我想TextUtils.TruncateAt.END,但我不能找出我应该定义bufstart,bufend和ellipsizedWidth.我特别找不到这个构造函数的任何好例子,或者它是否有助于实现我的目标.