【问题标题】:Android : I want to create loader with flight imageAndroid:我想用飞行图像创建装载机
【发布时间】:2018-04-23 06:22:54
【问题描述】:

我想在 android 中创建加载器,与附加的 gif 相同

提前致谢

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 到目前为止您尝试了什么?你身边的任何努力
  • 这将对您有所帮助。 stackoverflow.com/questions/26302282/… 或者你可以使用 glide 或 picasso 图像加载库。
  • 使用抽签动画
  • 为了实现这一点,我使用了 glide 库。

标签: android android-progressbar android-loadermanager android-loader


【解决方案1】:

你的图片中没有平面我更喜欢使用 ProgressBar

但我会更容易将 SeekBar 用作进度条

让我们以最简单的方式

在布局 XML 中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:hardwareAccelerated="false"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <SeekBar
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:background="#32aaef"
        android:id="@+id/sbHeight"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:max="100"
        android:progress="0"
        android:progressDrawable="@drawable/seekbar_as_progress"
        android:thumb="@drawable/plane"
        />
</LinearLayout>

seekbar_as_progress在哪里

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Define the background properties like color etc -->

    <item android:id="@android:id/background">
        <shape

            android:shape="line"
            android:useLevel="true">
            <stroke
                android:width="3dp"
                android:color="#c9c9c9"
                android:dashGap="20dp"
                android:dashWidth="3dp" />
        </shape>
    </item>

    <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape

                android:shape="line"
                android:useLevel="true">
            <stroke
                android:width="6dp"
                android:color="#ffffff"
                android:dashGap="20dp"
                android:dashWidth="4dp" />
            </shape>
        </clip>
    </item>
</layer-list>

@drawable/plane是平面图标

在你的活动中

  @Override
  protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    //        DountChart view = new DountChart(this);
            setContentView(R.layout.empty);

            final SeekBar sbHeight = findViewById(R.id.sbHeight);
            sbHeight.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            sbHeight.setOnTouchListener(new View.OnTouchListener(){
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });

            final int[] progress = {0};

            final Handler ha=new Handler();
            ha.postDelayed(new Runnable() {

                @Override
                public void run() {
                    //call function

                    if (progress[0] != 100){
                        AppLogger.log("Prog",progress[0]+"");
                        progress[0]= progress[0]+1;
                        sbHeight.setProgress(progress[0]);
                    ha.postDelayed(this, 100);
                    }
                }
            }, 100);

        }

and that`s All

【讨论】:

  • 这段代码对我有用。但是一旦达到 100,平面拇指图像就会停止。但我想自动移动平面拇指(不确定模式)
  • if (progress[0] != 100){ AppLogger.log("Prog",progress[0]+"");进度[0]=进度[0]+1; sbHeight.setProgress(进度[0]); ha.postDelayed(this, 100); } 其他{进度[0] = 0}
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多