Android 页码显示在底栏
Android page numbring displayed at the bottom bar
我想在我的应用程序底部显示一个页码,比如 3/10,滑动后,数字将是 4/10。
我的布局是用户禁止在它们之间滑动的 webview,我想在底部栏中指示 webview 当前索引,该索引将在每次滑动后更新。
基本布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="413.3dp"
android:id="@+id/tipsWebView"
android:layout_marginBottom="0.0dp" />
//bar position
</LinearLayout>
并显示我使用的不同网络视图:
adaptor.AddFragmentView((i, v, b) =>
{
if(m_swipeCounter < m_links.Length)
{
m_swipeCounter++;
}
else
{
m_swipeCounter= 0;
}
var view = i.Inflate(Resource.Layout.tab, v, false);
var client = new WebClient();
string htmlData = client.DownloadString(m_links[m_swipeCounter]);
htmlData +="<link rel=\"stylesheet\" type=\"text/css\" href=\"cssInject.css\">";
WebView tipsWebView = view.FindViewById<WebView>(Resource.Id.tipsWebView);
tipsWebView.SetWebViewClient(new WebViewClient());
tipsWebView.Settings.JavaScriptEnabled = true;
tipsWebView.LoadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "", null);
return view;
//create pager, pager adaptor to create the right webview link
});
因此索引将基于 m_swipeCounter
变量。
祝一切顺利。
使用 LinearLayout 可以,使用权重和其他东西,但使用 RelativeLayout
会运行更快
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tipsWebView"
android:layout_alignParentTop="true"
android:layout_above="@+id/bottomText"
/>
<TextView
android:id="@+id/bottomText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="0/0"
/>
</RelativeLayout>
我想在我的应用程序底部显示一个页码,比如 3/10,滑动后,数字将是 4/10。 我的布局是用户禁止在它们之间滑动的 webview,我想在底部栏中指示 webview 当前索引,该索引将在每次滑动后更新。 基本布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="413.3dp"
android:id="@+id/tipsWebView"
android:layout_marginBottom="0.0dp" />
//bar position
</LinearLayout>
并显示我使用的不同网络视图:
adaptor.AddFragmentView((i, v, b) =>
{
if(m_swipeCounter < m_links.Length)
{
m_swipeCounter++;
}
else
{
m_swipeCounter= 0;
}
var view = i.Inflate(Resource.Layout.tab, v, false);
var client = new WebClient();
string htmlData = client.DownloadString(m_links[m_swipeCounter]);
htmlData +="<link rel=\"stylesheet\" type=\"text/css\" href=\"cssInject.css\">";
WebView tipsWebView = view.FindViewById<WebView>(Resource.Id.tipsWebView);
tipsWebView.SetWebViewClient(new WebViewClient());
tipsWebView.Settings.JavaScriptEnabled = true;
tipsWebView.LoadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "", null);
return view;
//create pager, pager adaptor to create the right webview link
});
因此索引将基于 m_swipeCounter
变量。
祝一切顺利。
使用 LinearLayout 可以,使用权重和其他东西,但使用 RelativeLayout
会运行更快<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tipsWebView"
android:layout_alignParentTop="true"
android:layout_above="@+id/bottomText"
/>
<TextView
android:id="@+id/bottomText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="0/0"
/>
</RelativeLayout>