所以我有这个布局文件(下面).如您所见,没有填充或边距.dimen.xml文件也没有任何填充/边距.最后,我根本不以编程方式更改布局.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:padding="0dp"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/toolbarholder"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="16dp"
app:cardCornerRadius="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.v7.widget.Toolbar>
</android.support.v7.widget.CardView>
<ListView
android:layout_below="@+id/toolbarholder"
android:layout_above="@+id/cardroot"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_marginTop="0dp" />
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardroot"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/transparentblack"
app:cardCornerRadius="0dp"
app:cardElevation="16dp"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/buttonholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="3">
<ImageView
android:id="@+id/previous"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/previous"
android:layout_weight="1"/>
<ImageView
android:id="@+id/play"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/play"
android:layout_weight="1"/>
<ImageView
android:id="@+id/next"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@drawable/next"
android:layout_weight="1"/>
</LinearLayout>
<SeekBar
android:id="@+id/seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonholder" …Run Code Online (Sandbox Code Playgroud) 我有一个扩展 Drawable 的自定义类,如下所示,它旨在绘制弧线。从控制 Drawable 的 MainActivity 中,我根据一些输入值重新绘制它,并将这些输入值转换为形状的适当“角度”。例如
这是可绘制对象的初始状态:

这是可绘制对象的第二个状态:
红色箭头表示我想要实现的运动
我试图用扫动动作“动画”从状态 1 到状态 2 的变化。关于如何做到这一点有什么想法吗?我是否应该多次重绘形状,逐渐在状态一和状态二之间过渡?
我的绘图代码:
public class CircleLoadingBar extends Drawable implements Drawable.Callback{
private Paint paint;
private Canvas canvas;
private float angle;
private RectF outterCircle;
private float padding=30;
public void invalidateDrawable(Drawable drawable){
final Callback callback = getCallback();
if (callback != null) {
callback.invalidateDrawable(this);
}
}
public void scheduleDrawable(Drawable drawable, Runnable runnable, long l){
invalidateDrawable(drawable);
}
public void unscheduleDrawable(Drawable drawable,Runnable runnable){
//empty
}
public CircleLoadingBar(){
this(0);
}
public CircleLoadingBar( int angle){ …Run Code Online (Sandbox Code Playgroud)