我成功从服务器获取阿拉伯语文本.检索到的文本我希望在代码中显示,但显示框而不是阿拉伯文本.假设t数组值是来自服务器的阿拉伯语文本.
string[] t={" "};
Textview tv = (Textview) findviewByid(R.id.text);
tv.setText(t[0]);
Run Code Online (Sandbox Code Playgroud) 我有以下布局
<?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">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="13">
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
<ImageButton android:background="@null" android:id="@+id/back" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/back" android:padding="10dip" />
</LinearLayout>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
<ImageButton android:background="@null" android:id="@+id/forward" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/forward" android:padding="10dip" />
</LinearLayout>
</LinearLayout>
<RelativeLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" >
<ImageButton android:background="@null" android:id="@+id/special" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/barcode" android:padding="10dip" android:layout_gravity="right"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
出于这个问题的目的,我只关心布局的下半部分.现在它包含3个图像按钮.前两个,我希望彼此相邻,左对齐.第三个,我希望与右侧对齐.
按原样,前2个按钮是我想要它们的位置,但是第3个按钮是固定保持左对齐的.我该如何正确对齐.
我有PreferenceScreen和一些PreferenceCheckBoxes.我想更改textColor和textSize的标题和摘要以及CheckBox的图像选中和取消选中.所以我android:layout用来改变这个属性.
我的ChceckBoxPreference:
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:key="temp"
android:title="@string/title"
android:summary="@string/summary"
android:defaultValue="true"
/>
Run Code Online (Sandbox Code Playgroud)
当我使用android:widgetLayout它看起来很奇怪.这是我的preference_checkbox.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
>
<TextView
android:id="@+android:id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="20sp"
/>
<TextView
android:id="@+android:id/summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="14sp"
/>
</LinearLayout>
<CheckBox
android:id="@+android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
带有id @+android:id/title和摘要的标题@+android:id/summary显示正确的值.但是,尽管默认值和id的复选框@+android:id/checkbox无法正常工作.它没有显示正确的值,我无法更改首选项中保留的值.不使用任何布局,我可以通过触摸整个CheckBoxPreference来更改复选框的值.但现在(使用我的布局)我只能通过触摸此复选框来更改复选框的值.如何以正确的方式为所有功能制作CheckBoxPreference的布局?
我使用如何在Android中支持阿拉伯语文本的课程?显示阿拉伯文字.在Android 2.1 - 2.3文本位于左侧,所以我使用android:gravity ="right",但在Android 3.0+阿拉伯语文本已在右侧自动对齐,如果我使用android:gravity ="right"in将左侧对齐.如何在不同的Android版本中使文本与相同的文本对齐?