如何旋转android小部件文本?还有一些我不明白的事情
我试图让我的 Android 小部件内的文本框/文本视图旋转,但我不知道如何操作。
问题:
- 如何使里面的文本旋转,就像小部件从左到右一样? 2.remoteViews.setTextViewText
- 如何与动画一起使用?
这是我尝试过的小部件示例代码,想要使文本旋转。
public class WatchWidget extends AppWidgetProvider{
@Override
public void onUpdate( Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds )
{
DateFormat format = SimpleDateFormat.getTimeInstance( SimpleDateFormat.MEDIUM, Locale.getDefault() );
RemoteViews remoteViews = new RemoteViews( context.getPackageName(), R.layout.main );
ComponentName watchWidget = new ComponentName( context, WatchWidget.class );
remoteViews.setTextViewText( R.id.widget_textview, "Time = " + format.format( new Date()));
appWidgetManager.updateAppWidget( watchWidget, remoteViews );
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="300dp"
android:layout_height="72dp"
android:layout_margin="8dip"
android:background="@drawable/background"
android:orientation="horizontal" >
<TextView
android:id="@+id/widget_textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="4dip"
android:layout_weight="16"
android:gravity="center_vertical|center_horizontal"
android:textColor="@android:color/black"
android:textSize="8pt" />
</LinearLayout>
I am try to make the textbox/textview inside my android widget rotate, but i dont know how to.
Questions:
- how to make the text inside rotate, like from left to right for widget?
2. - remoteViews.setTextViewText how can this work with animation?
Here is the widget example code I played around and wanted to make the text rotate.
public class WatchWidget extends AppWidgetProvider{
@Override
public void onUpdate( Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds )
{
DateFormat format = SimpleDateFormat.getTimeInstance( SimpleDateFormat.MEDIUM, Locale.getDefault() );
RemoteViews remoteViews = new RemoteViews( context.getPackageName(), R.layout.main );
ComponentName watchWidget = new ComponentName( context, WatchWidget.class );
remoteViews.setTextViewText( R.id.widget_textview, "Time = " + format.format( new Date()));
appWidgetManager.updateAppWidget( watchWidget, remoteViews );
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="300dp"
android:layout_height="72dp"
android:layout_margin="8dip"
android:background="@drawable/background"
android:orientation="horizontal" >
<TextView
android:id="@+id/widget_textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="4dip"
android:layout_weight="16"
android:gravity="center_vertical|center_horizontal"
android:textColor="@android:color/black"
android:textSize="8pt" />
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论