我正在尝试将图片与图片并排设置,但不能这样做
图片
try {
resultBmp.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
userImage = Image.getInstance(stream.toByteArray());
userImage.setAlignment(Image.ALIGN_RIGHT );
userImage.scaleToFit(280 , 280);
}catch (Exception c){
}
多文字
document.add(new Paragraph("Name : "+ personal_info_data.getString("FN" , "")));
document.add(new Paragraph("Date Of Birth : "+ personal_info_data.getString("DOB" , "")));
document.add(new Paragraph("Birth Place : "+ personal_info_data.getString("B" , "")));
document.add(new Paragraph("Nationality : "+ personal_info_data.getString("N" , "")));
document.add(new Paragraph("Phone Number : "+ personal_info_data.getString("PN" , "")));
document.add(new Paragraph("Email : "+ personal_info_data.getString("EA" , "")));
document.add(new Paragraph("Address : "+ personal_info_data.getString("A" , "")));
document.add(new Paragraph("Current Place : "+ personal_info_data.getString("CP" , "")));
document.add(new Paragraph("Martial Status : "+ personal_info_data.getString("MS" , "")));
document.add(new Paragraph("Self Description : "+ personal_info_data.getString("SI" , "")));
如图所示,我希望所有文本与图像并排,但我不想实现表格,我不需要边界..任何方式我怎样才能实现这一目标。
答案 0 :(得分:-1)
你可以用双向方式做到这一点。
TextView
文件中设置ImageView
和xml
,如下所示在RelativeLayout
文件中的xml
添加ImageView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@mipmap/ic_launcher"
android:id="@+id/imageView"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toEndOf="@id/imageView"
android:id="@+id/linearLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Name"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Email"
android:textSize="18sp"/>
</LinearLayout>
</RelativeLayout>
为每个字段添加TextView
并按编程方式为其分配值
textView.setText(text);
LinearLayout
,如下所示。xml文件。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@mipmap/ic_launcher"
android:id="@+id/imageView"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_toEndOf="@id/imageView"
android:id="@+id/linearLayout"/>
</RelativeLayout>
Java文件。
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
TextView textView1 = new TextView(this);
textView1.setText("Name");
linearLayout.addView(textView1);
TextView textView2 = new TextView(this);
textView2.setText("Email");
linearLayout.addView(textView2);
将其放入onCreate
并根据需要添加任意数量的视图。
然后你会得到this