本文介绍了进度栏,图像居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天大家好,我正在尝试创建自定义进度栏,为此我创建了一个spinner_inner和spinner_outer,但是我的内部尺寸很大,并且与外部重叠.
Hi guys today i'am trying to do my custom progress bar, for that i created a spinner_inner and a spinner_outer, but my inner size is to large and overlaps the outer.
我的活动
<ProgressBar
style="@style/Spinner"
android:layout_width="100dp"
android:layout_height="100dp"
android:indeterminateDrawable="@drawable/loading" />
<TextView
android:id="@+id/login_status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:fontFamily="sans-serif-light"
android:text="@string/login_progress_signing_in"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
我的风格
<style name="Spinner">
<item name="android:indeterminate">true</item>
<item name="android:indeterminateDrawable">@drawable/spinner_outer</item>
<item name="android:indeterminateDuration">2000</item>
<item name="android:indeterminateOnly">true</item>
</style>
我的xml
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/spinner_inner"/>
<item>
<rotate
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<bitmap
android:antialias="true"
android:filter="true"
android:src="@drawable/spinner_outer" />
</rotate>
</item>
我已经搜索了答案,但是没有成功
I had already searched for an answer but no sucess
推荐答案
因此,在没人回答我之后,我找到了自己的方式.
So after nobody answer me i find my own way.
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/loading_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout
android:id="@+id/relative_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/spinner_inner"
android:layout_centerInParent="true" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminateDrawable="@drawable/loading"
android:visibility="visible" />
</RelativeLayout>
<TextView
android:id="@+id/status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:fontFamily="sans-serif-light"
android:text="@string/loading_data"
android:textAppearance="?android:attr/textAppearanceMedium" />
旋转器
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<rotate
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
<bitmap
android:antialias="true"
android:filter="true"
android:src="@drawable/spinner_outer" />
</rotate>
</item>
</layer-list>
这篇关于进度栏,图像居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!