阅读Google提供的有限文档后,我感觉可以通过简单地创建一个新样式并将其分配给ProgressBar的样式属性来更改ProgressBar/ProgressDialog的外观(可绘制).但我不能让它正常工作.这是我到目前为止所做的:
我创建了这样的形状(mp2.xml)
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="4"
android:thicknessRatio="4"
android:useLevel="false">
<size android:width="50dip" android:height="50dip" />
<gradient android:type="sweep" android:useLevel="false" android:startColor="#300000ff" android:centerColor="#500000ff" android:endColor="#ff0000ff" />
</shape>
Run Code Online (Sandbox Code Playgroud)
然后像这样创建了一个动画(mp3.xml):
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="30" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="30" android:toDegrees="60" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="60" android:toDegrees="90" android:repeatCount="1" />
</item>
<item android:duration="70">
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/mp2" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="90" android:toDegrees="120" android:repeatCount="1" />
</item>
<item android:duration="70"> …Run Code Online (Sandbox Code Playgroud) activity_main.xml正如你所见,我在下方,高度设定为40度.
在MyEclipse中,它看起来如下:

但是当我在手机上运行时,它看起来如下:

所以我的问题是为什么进度条的真实高度不是我设置的那个?如何增加进度条的高度?
我正试图在我的框架顶部放置一个水平进度条.但似乎有填充,我根本无法删除.有帮助吗?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar android:id="@+id/flv_progress_bar"
android:layout_width="fill_parent"
style="@android:style/Widget.Holo.ProgressBar.Horizontal"
android:indeterminateOnly="true"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) 该NestedScrollView提供的支持库不正确地与工作WebView(相关错误报告).因此我已经开始实现NestedScrollingChilda WebView并且它似乎对第一个滚动工作正常,折叠和扩展AppBarLayout但是任何后续滚动都无法折叠它.
我的WebView:
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingChildHelper;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;
/**
* Created by carlos on 2/19/16.
*/
public class MyWebView extends WebView implements NestedScrollingChild {
private static final String TAG = MyWebView.class.getSimpleName();
private NestedScrollingChildHelper helper = new NestedScrollingChildHelper(this);
public MyWebView(Context context) {
super(context);
}
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyWebView(Context context, AttributeSet …Run Code Online (Sandbox Code Playgroud) android webview android-support-library android-collapsingtoolbarlayout android-appbarlayout
由于这段代码我定义了一个进度条:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:id="@+id/fragment_article_progressBar"
android:visibility="visible"
/>
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_article_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,在上方和下方添加了一些填充 ProgressBar

这似乎不太自然.
它是水平的正常风格ProgressBar吗?如果不是,我该如何解决?
干杯
我尝试通过使用以下XML将水平进度条放在工具栏的顶部.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Toolbar -->
<include layout="@layout/toolbar"/>
<!-- http://stackoverflow.com/questions/14171471/remove-vertical-padding-from-horizontal-progressbar -->
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:id="@+id/progress_bar"
android:layout_gravity="top"
android:layout_marginBottom="0dp"
android:layout_marginTop="-3dp"
android:progress="2000"
android:max="10000" />
</FrameLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:id="@+id/progress_bar2"
android:layout_gravity="top"
android:layout_marginBottom="0dp"
android:layout_marginTop="-3dp"
android:progress="2000"
android:max="10000" />
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<!-- android:elevation="4dp" is used due to http://www.google.com/design/spec/what-is-material/elevation-shadows.html#elevation-shadows-elevation-android- -->
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
这在Android 4+下运行得非常好.这是Android 4+的屏幕截图
但是,当涉及到Android 5+时,工具栏顶部不会显示水平进度条.
如果我删除线 …