我是Android新手,我尝试格式化古兰经页面内容。它是逐字逐句的。我必须将它并排显示右边。
请建议我如何并排显示
样式格式
<style name="WordStyle" >
<item name="android:textColor">#000000</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="AyaStyle">
<item name="android:textColor">#008866</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
XML格式
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:textDirection="rtl"
tools:context="info.studyquran.project.study.MainActivity">
<TextView
android:tag="2:6:1"
style="@style/WordStyle"
android:onClick="onWord"
android:text="إِنَّ "
/>
<TextView
android:tag="2:6:2"
style="@style/WordStyle"
android:onClick="onWord"
android:text="ٱلَّذِينَ "
/>
<TextView
android:tag="2:6:3"
style="@style/WordStyle"
android:onClick="onWord"
android:text="كَفَرُوا۟ "
/>
<TextView
android:tag="2:6:4"
style="@style/WordStyle"
android:onClick="onWord"
android:text="سَوَآءٌ "
/>
<TextView
android:tag="2:6:5"
style="@style/WordStyle"
android:onClick="onWord"
android:text="عَلَيْهِمْ "
/>
<TextView
android:tag="2:6:6"
style="@style/WordStyle"
android:onClick="onWord"
android:text="ءَأَنذَرْتَهُمْ "
/>
<TextView
android:tag="2:6:7"
style="@style/WordStyle"
android:onClick="onWord"
android:text="أَمْ "
/>
<TextView
android:tag="2:6:8"
style="@style/WordStyle"
android:onClick="onWord"
android:text="لَمْ "
/>
<TextView
android:tag="2:6:9"
style="@style/WordStyle"
android:onClick="onWord"
android:text="تُنذِرْهُمْ "
/>
<TextView
android:tag="2:6:10"
style="@style/WordStyle"
android:onClick="onWord"
android:text="لَا "
/>
<TextView
android:tag="2:6:11"
style="@style/WordStyle"
android:onClick="onWord"
android:text="يُؤْمِنُونَ "
/>
<TextView
style="@style/AyaStyle"
android:tag="2:6"
android:onClick="onAya"
android:text=" ﴿٦﴾ "
/>
<TextView android:tag="2:7:1" style="@style/WordStyle" android:onClick="onWord" android:text="خَتَمَ " /><TextView android:tag="2:7:2" style="@style/WordStyle" android:onClick="onWord" android:text="ٱللَّهُ " /><TextView android:tag="2:7:3" style="@style/WordStyle" android:onClick="onWord" android:text="عَلَىٰ " /><TextView android:tag="2:7:4" style="@style/WordStyle" android:onClick="onWord" android:text="قُلُوبِهِمْ " /><TextView android:tag="2:7:5" style="@style/WordStyle" android:onClick="onWord" android:text="وَعَلَىٰ " /><TextView android:tag="2:7:6" style="@style/WordStyle" android:onClick="onWord" android:text="سَمْعِهِمْ " /><TextView android:tag="2:7:7" style="@style/WordStyle" android:onClick="onWord" android:text="وَعَلَىٰٓ " /><TextView android:tag="2:7:8" style="@style/WordStyle" android:onClick="onWord" android:text="أَبْصَٰرِهِمْ " /><TextView android:tag="2:7:9" style="@style/WordStyle" android:onClick="onWord" android:text="غِشَٰوَةٌ " /><TextView android:tag="2:7:10" style="@style/WordStyle" android:onClick="onWord" android:text="وَلَهُمْ " /><TextView android:tag="2:7:11" style="@style/WordStyle" android:onClick="onWord" android:text="عَذَابٌ " /><TextView android:tag="2:7:12" style="@style/WordStyle" android:onClick="onWord" android:text="عَظِيمٌ " /><TextView style="@style/AyaStyle" android:tag="2:7" android:onClick="onAya" android:text=" ﴿٧﴾ " />
<TextView android:tag="2:8:1" style="@style/WordStyle" android:onClick="onWord" android:text="وَمِنَ " /><TextView android:tag="2:8:2" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلنَّاسِ " /><TextView android:tag="2:8:3" style="@style/WordStyle" android:onClick="onWord" android:text="مَن " /><TextView android:tag="2:8:4" style="@style/WordStyle" android:onClick="onWord" android:text="يَقُولُ " /><TextView android:tag="2:8:5" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنَّا " /><TextView android:tag="2:8:6" style="@style/WordStyle" android:onClick="onWord" android:text="بِٱللَّهِ " /><TextView android:tag="2:8:7" style="@style/WordStyle" android:onClick="onWord" android:text="وَبِٱلْيَوْمِ " /><TextView android:tag="2:8:8" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلْءَاخِرِ " /><TextView android:tag="2:8:9" style="@style/WordStyle" android:onClick="onWord" android:text="وَمَا " /><TextView android:tag="2:8:10" style="@style/WordStyle" android:onClick="onWord" android:text="هُم " /><TextView android:tag="2:8:11" style="@style/WordStyle" android:onClick="onWord" android:text="بِمُؤْمِنِينَ " /><TextView style="@style/AyaStyle" android:tag="2:8" android:onClick="onAya" android:text=" ﴿٨﴾ " />
<TextView android:tag="2:9:1" style="@style/WordStyle" android:onClick="onWord" android:text="يُخَٰدِعُونَ " /><TextView android:tag="2:9:2" style="@style/WordStyle" android:onClick="onWord" android:text="ٱللَّهَ " /><TextView android:tag="2:9:3" style="@style/WordStyle" android:onClick="onWord" android:text="وَٱلَّذِينَ " /><TextView android:tag="2:9:4" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنُوا۟ " /><TextView android:tag="2:9:5" style="@style/WordStyle" android:onClick="onWord" android:text="وَمَا " /><TextView android:tag="2:9:6" style="@style/WordStyle" android:onClick="onWord" android:text="يَخْدَعُونَ " /><TextView android:tag="2:9:7" style="@style/WordStyle" android:onClick="onWord" android:text="إِلَّآ " /><TextView android:tag="2:9:8" style="@style/WordStyle" android:onClick="onWord" android:text="أَنفُسَهُمْ " /><TextView android:tag="2:9:9" style="@style/WordStyle" android:onClick="onWord" android:text="وَمَا " /><TextView android:tag="2:9:10" style="@style/WordStyle" android:onClick="onWord" android:text="يَشْعُرُونَ " /><TextView style="@style/AyaStyle" android:tag="2:9" android:onClick="onAya" android:text=" ﴿٩﴾ " />
<TextView android:tag="2:10:1" style="@style/WordStyle" android:onClick="onWord" android:text="فِى " /><TextView android:tag="2:10:2" style="@style/WordStyle" android:onClick="onWord" android:text="قُلُوبِهِم " /><TextView android:tag="2:10:3" style="@style/WordStyle" android:onClick="onWord" android:text="مَّرَضٌ " /><TextView android:tag="2:10:4" style="@style/WordStyle" android:onClick="onWord" android:text="فَزَادَهُمُ " /><TextView android:tag="2:10:5" style="@style/WordStyle" android:onClick="onWord" android:text="ٱللَّهُ " /><TextView android:tag="2:10:6" style="@style/WordStyle" android:onClick="onWord" android:text="مَرَضًا " /><TextView android:tag="2:10:7" style="@style/WordStyle" android:onClick="onWord" android:text="وَلَهُمْ " /><TextView android:tag="2:10:8" style="@style/WordStyle" android:onClick="onWord" android:text="عَذَابٌ " /><TextView android:tag="2:10:9" style="@style/WordStyle" android:onClick="onWord" android:text="أَلِيمٌۢ " /><TextView android:tag="2:10:10" style="@style/WordStyle" android:onClick="onWord" android:text="بِمَا " /><TextView android:tag="2:10:11" style="@style/WordStyle" android:onClick="onWord" android:text="كَانُوا۟ " /><TextView android:tag="2:10:12" style="@style/WordStyle" android:onClick="onWord" android:text="يَكْذِبُونَ " /><TextView style="@style/AyaStyle" android:tag="2:10" android:onClick="onAya" android:text=" ﴿١٠﴾ " />
<TextView android:tag="2:11:1" style="@style/WordStyle" android:onClick="onWord" android:text="وَإِذَا " /><TextView android:tag="2:11:2" style="@style/WordStyle" android:onClick="onWord" android:text="قِيلَ " /><TextView android:tag="2:11:3" style="@style/WordStyle" android:onClick="onWord" android:text="لَهُمْ " /><TextView android:tag="2:11:4" style="@style/WordStyle" android:onClick="onWord" android:text="لَا " /><TextView android:tag="2:11:5" style="@style/WordStyle" android:onClick="onWord" android:text="تُفْسِدُوا۟ " /><TextView android:tag="2:11:6" style="@style/WordStyle" android:onClick="onWord" android:text="فِى " /><TextView android:tag="2:11:7" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلْأَرْضِ " /><TextView android:tag="2:11:8" style="@style/WordStyle" android:onClick="onWord" android:text="قَالُوٓا۟ " /><TextView android:tag="2:11:9" style="@style/WordStyle" android:onClick="onWord" android:text="إِنَّمَا " /><TextView android:tag="2:11:10" style="@style/WordStyle" android:onClick="onWord" android:text="نَحْنُ " /><TextView android:tag="2:11:11" style="@style/WordStyle" android:onClick="onWord" android:text="مُصْلِحُونَ " /><TextView style="@style/AyaStyle" android:tag="2:11" android:onClick="onAya" android:text=" ﴿١١﴾ " />
<TextView android:tag="2:12:1" style="@style/WordStyle" android:onClick="onWord" android:text="أَلَآ " /><TextView android:tag="2:12:2" style="@style/WordStyle" android:onClick="onWord" android:text="إِنَّهُمْ " /><TextView android:tag="2:12:3" style="@style/WordStyle" android:onClick="onWord" android:text="هُمُ " /><TextView android:tag="2:12:4" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلْمُفْسِدُونَ " /><TextView android:tag="2:12:5" style="@style/WordStyle" android:onClick="onWord" android:text="وَلَٰكِن " /><TextView android:tag="2:12:6" style="@style/WordStyle" android:onClick="onWord" android:text="لَّا " /><TextView android:tag="2:12:7" style="@style/WordStyle" android:onClick="onWord" android:text="يَشْعُرُونَ " /><TextView style="@style/AyaStyle" android:tag="2:12" android:onClick="onAya" android:text=" ﴿١٢﴾ " />
<TextView android:tag="2:13:1" style="@style/WordStyle" android:onClick="onWord" android:text="وَإِذَا " /><TextView android:tag="2:13:2" style="@style/WordStyle" android:onClick="onWord" android:text="قِيلَ " /><TextView android:tag="2:13:3" style="@style/WordStyle" android:onClick="onWord" android:text="لَهُمْ " /><TextView android:tag="2:13:4" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامِنُوا۟ " /><TextView android:tag="2:13:5" style="@style/WordStyle" android:onClick="onWord" android:text="كَمَآ " /><TextView android:tag="2:13:6" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنَ " /><TextView android:tag="2:13:7" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلنَّاسُ " /><TextView android:tag="2:13:8" style="@style/WordStyle" android:onClick="onWord" android:text="قَالُوٓا۟ " /><TextView android:tag="2:13:9" style="@style/WordStyle" android:onClick="onWord" android:text="أَنُؤْمِنُ " /><TextView android:tag="2:13:10" style="@style/WordStyle" android:onClick="onWord" android:text="كَمَآ " /><TextView android:tag="2:13:11" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنَ " /><TextView android:tag="2:13:12" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلسُّفَهَآءُ " /><TextView android:tag="2:13:13" style="@style/WordStyle" android:onClick="onWord" android:text="أَلَآ " /><TextView android:tag="2:13:14" style="@style/WordStyle" android:onClick="onWord" android:text="إِنَّهُمْ " /><TextView android:tag="2:13:15" style="@style/WordStyle" android:onClick="onWord" android:text="هُمُ " /><TextView android:tag="2:13:16" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلسُّفَهَآءُ " /><TextView android:tag="2:13:17" style="@style/WordStyle" android:onClick="onWord" android:text="وَلَٰكِن " /><TextView android:tag="2:13:18" style="@style/WordStyle" android:onClick="onWord" android:text="لَّا " /><TextView android:tag="2:13:19" style="@style/WordStyle" android:onClick="onWord" android:text="يَعْلَمُونَ " /><TextView style="@style/AyaStyle" android:tag="2:13" android:onClick="onAya" android:text=" ﴿١٣﴾ " />
<TextView android:tag="2:14:1" style="@style/WordStyle" android:onClick="onWord" android:text="وَإِذَا " /><TextView android:tag="2:14:2" style="@style/WordStyle" android:onClick="onWord" android:text="لَقُوا۟ " /><TextView android:tag="2:14:3" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلَّذِينَ " /><TextView android:tag="2:14:4" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنُوا۟ " /><TextView android:tag="2:14:5" style="@style/WordStyle" android:onClick="onWord" android:text="قَالُوٓا۟ " /><TextView android:tag="2:14:6" style="@style/WordStyle" android:onClick="onWord" android:text="ءَامَنَّا " /><TextView android:tag="2:14:7" style="@style/WordStyle" android:onClick="onWord" android:text="وَإِذَا " /><TextView android:tag="2:14:8" style="@style/WordStyle" android:onClick="onWord" android:text="خَلَوْا۟ " /><TextView android:tag="2:14:9" style="@style/WordStyle" android:onClick="onWord" android:text="إِلَىٰ " /><TextView android:tag="2:14:10" style="@style/WordStyle" android:onClick="onWord" android:text="شَيَٰطِينِهِمْ " /><TextView android:tag="2:14:11" style="@style/WordStyle" android:onClick="onWord" android:text="قَالُوٓا۟ " /><TextView android:tag="2:14:12" style="@style/WordStyle" android:onClick="onWord" android:text="إِنَّا " /><TextView android:tag="2:14:13" style="@style/WordStyle" android:onClick="onWord" android:text="مَعَكُمْ " /><TextView android:tag="2:14:14" style="@style/WordStyle" android:onClick="onWord" android:text="إِنَّمَا " /><TextView android:tag="2:14:15" style="@style/WordStyle" android:onClick="onWord" android:text="نَحْنُ " /><TextView android:tag="2:14:16" style="@style/WordStyle" android:onClick="onWord" android:text="مُسْتَهْزِءُونَ " /><TextView style="@style/AyaStyle" android:tag="2:14" android:onClick="onAya" android:text=" ﴿١٤﴾ " />
<TextView android:tag="2:15:1" style="@style/WordStyle" android:onClick="onWord" android:text="ٱللَّهُ " /><TextView android:tag="2:15:2" style="@style/WordStyle" android:onClick="onWord" android:text="يَسْتَهْزِئُ " /><TextView android:tag="2:15:3" style="@style/WordStyle" android:onClick="onWord" android:text="بِهِمْ " /><TextView android:tag="2:15:4" style="@style/WordStyle" android:onClick="onWord" android:text="وَيَمُدُّهُمْ " /><TextView android:tag="2:15:5" style="@style/WordStyle" android:onClick="onWord" android:text="فِى " /><TextView android:tag="2:15:6" style="@style/WordStyle" android:onClick="onWord" android:text="طُغْيَٰنِهِمْ " /><TextView android:tag="2:15:7" style="@style/WordStyle" android:onClick="onWord" android:text="يَعْمَهُونَ " /><TextView style="@style/AyaStyle" android:tag="2:15" android:onClick="onAya" android:text=" ﴿١٥﴾ " />
<TextView android:tag="2:16:1" style="@style/WordStyle" android:onClick="onWord" android:text="أُو۟لَٰٓئِكَ " /><TextView android:tag="2:16:2" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلَّذِينَ " /><TextView android:tag="2:16:3" style="@style/WordStyle" android:onClick="onWord" android:text="ٱشْتَرَوُا۟ " /><TextView android:tag="2:16:4" style="@style/WordStyle" android:onClick="onWord" android:text="ٱلضَّلَٰلَةَ " /><TextView android:tag="2:16:5" style="@style/WordStyle" android:onClick="onWord" android:text="بِٱلْهُدَىٰ " /><TextView android:tag="2:16:6" style="@style/WordStyle" android:onClick="onWord" android:text="فَمَا " /><TextView android:tag="2:16:7" style="@style/WordStyle" android:onClick="onWord" android:text="رَبِحَت " /><TextView android:tag="2:16:8" style="@style/WordStyle" android:onClick="onWord" android:text="تِّجَٰرَتُهُمْ " /><TextView android:tag="2:16:9" style="@style/WordStyle" android:onClick="onWord" android:text="وَمَا " /><TextView android:tag="2:16:10" style="@style/WordStyle" android:onClick="onWord" android:text="كَانُوا۟ " /><TextView android:tag="2:16:11" style="@style/WordStyle" android:onClick="onWord" android:text="مُهْتَدِينَ " /><TextView style="@style/AyaStyle" android:tag="2:16" android:onClick="onAya" android:text=" ﴿١٦﴾ " />
</LinearLayout>
答案 0 :(得分:1)
好的,你可以在这种情况下使用网格视图.. 这是你如何做到这一点。
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="100dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</GridView>
创建单独的items.xml
<TextView
android:id="@+id/grid_item_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:layout_marginTop="5px"
android:textSize="15px" >
</TextView>
设置类似这样的自定义适配器
public class TextViewAdapter extends BaseAdapter {
private Context context;
private final String[] textViewValues;
public TextViewAdapter(Context context, String[] textViewValues) {
this.context = context;
this.textViewValues = textViewValues;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) {
gridView = new View(context);
// get layout from mobile.xml
gridView = inflater.inflate(R.layout.item, null);
// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label);
textView.setText(textViewValues[position]);
} else {
gridView = (View) convertView;
}
return gridView;
}
@Override
public int getCount() {
return textViewValues.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
}
然后,最后在主类中设置适配器
gridView.setAdapter(new TextViewAdapter(this, YourArrayofText));
答案 1 :(得分:0)
只需添加android:gravity =&#34;对&#34;在LinearLayout中,像这样:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:textDirection="rtl"
tools:context="info.studyquran.project.study.MainActivity"
android:gravity="right">
答案 2 :(得分:0)
在线性布局
中更改强>
android:orientation="vertical"
以强>
android:orientation="horizontal"