我在我的应用程序中使用ViewPager并且我想支持RTL,但是当我将我的设备语言改为RTl时,它似乎无法正常工作.
我希望标签从右侧开始(右侧的第一个片段).
请帮我解决一下.
编辑:这是它的图片: 标签从左侧开始
这是我的代码:
activity_main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/app_bar_main"
android:id="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start"
android:layout_below="@id/toolbar_actionbar">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/fragment_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
</com.google.android.gms.ads.AdView>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java:
package ...;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; …
Run Code Online (Sandbox Code Playgroud) 我Fresco
在我的应用程序中使用库来加载图像。问题是我无法将图像高度设置为"wrap_content"
因为 库中"wrap_content"
不支持Fresco
。那么如何使用DraweeView
?使我的图像看起来不错?我在这里查看,但找不到解决此问题的方法:frescolib/wrap_content
例如:
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/intro_image1"
android:layout_width="match_parent"
android:layout_height= // Can't use "wrap_content"
fresco:placeholderImage="@drawable/placeholder_image" />
Run Code Online (Sandbox Code Playgroud)
顺便说一句,图像尺寸为 730*760
我的应用程序中有首选项活动,它具有 ListPreference,因此用户可以为应用程序选择语言。
在用户关闭 Preferences 活动后,应用程序会立即显示新语言。
我想为 ListPreference 创建一个侦听器,以便在触发侦听器时应用程序将重新启动(就在用户从 ListPreference 中选择语言/选择项目之后)。
我怎样才能做到这一点?
设置活动:
public class SettingsActivity extends AppCompatPreferenceActivity {
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference …
Run Code Online (Sandbox Code Playgroud) java android preferenceactivity android-preferences listpreference