按钮内的动画文本
Animate text inside button
我有带有固定大小按钮的回收视图:
<Button
android:text="Category"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/categoryButton"
style="@style/custom_button" />
在按钮内输入大文本时出现的情况:
但如果文本大于按钮宽度,我希望文本在其中移动。
我正在使用 Xamarin.Android,但我很乐意在 Java 上获得任何帮助。
用ScrollView包裹起来
例如
<ScrollView
android:layout_width="100dp"
android:layout_height="wrap_content">
<Button
android:text="Category"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/categoryButton"
style="@style/custom_button" />
</ScrollView>
如果您想让文本水平滚动,您可以在按钮中使用 'marquee' 属性。
布局:
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="Abracadabra" />
并在代码中;将按钮的选择设置为 true。
button.setSelected(true)
我有带有固定大小按钮的回收视图:
<Button
android:text="Category"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/categoryButton"
style="@style/custom_button" />
在按钮内输入大文本时出现的情况:
但如果文本大于按钮宽度,我希望文本在其中移动。
我正在使用 Xamarin.Android,但我很乐意在 Java 上获得任何帮助。
用ScrollView包裹起来
例如
<ScrollView
android:layout_width="100dp"
android:layout_height="wrap_content">
<Button
android:text="Category"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/categoryButton"
style="@style/custom_button" />
</ScrollView>
如果您想让文本水平滚动,您可以在按钮中使用 'marquee' 属性。
布局:
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="Abracadabra" />
并在代码中;将按钮的选择设置为 true。
button.setSelected(true)