我已将列表中的大小设置为16,但是当我运行我的代码时它将变为7并且列表中的文本变得非常小。我也尝试在运行时更改大小,但仍然是大小变小。 如果我在我的活动之间切换3-4次,那么它的大小在列表中就可以了,哪个可以让我获得可见性。但是当它到来时它非常小。
以下是我的代码:
public View getView(int position,View convertView,ViewGroup parent){
View vi = convertView;
ViewHolder holder;
tempValues = null;
tempValues = (ModelLoveQuotes) data.get(position);
if (convertView == null) {
vi = inflater.inflate(R.layout.tabitem, null);
holder = new ViewHolder();
holder.text = (TextView) vi.findViewById(R.id.tv_tablerow);
float textSize1 = holder.text.getTextSize();
Log.d(TAG,"manish text size1: "+textSize1); //this is coming 7
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
float textSize2 = holder.text.getTextSize();
Log.d(TAG,"manish text size2: "+textSize2); //this is coming 7
}
boolean favExist = false;
if (al_favSMS != null) {
for (ModelFavoriteSMS favSms : al_favSMS) {
if (favSms.getMesssage().equalsIgnoreCase(tempValues.getBody())) {
favExist = true;
break;
} else {
favExist = false;
}
}
}
if (favExist) {
holder.image1 = (ImageView) vi.findViewById(R.id.image2);
holder.image1.setImageResource(R.drawable.ic_favorite_black);
} else {
holder.image1 = (ImageView) vi.findViewById(R.id.image2);
holder.image1.setImageResource(R.drawable.ic_favorite_border_black);
}
if (data.size() <= 0) {
holder.text.setText("No Data");
} else {
holder.text.setMaxLines(2);
holder.text.setText(tempValues.getBody());
holder.image1.setOnClickListener(new OnItemClickListener(position));
vi.setOnClickListener(new OnItemClickListener(position));
}
return vi;
}
tabitem.xml
<?xml version="1.0" encoding="UTF-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:background="@drawable/btn_trans"
android:gravity="center_vertical"
android:minHeight="60dp">
<TableRow>
<TextView
android:id="@+id/tv_tablerow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="5dip"
android:layout_span="1"
android:layout_weight="1"
android:textColor="@color/Black"
android:textSize="16sp" <!-- I have defined it 16sp here -->
android:textStyle="normal"
android:typeface="serif" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/image2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right|center_vertical"
android:padding="2dp"
android:src="@drawable/ic_favorite_border_black"
android:tag="fav"
android:visibility="gone" />
</LinearLayout>
</TableRow>
</TableLayout>
我标记了值的来源7以及我将其定义为16sp的位置。