优化界面布局

This commit is contained in:
pppscn 2021-02-11 23:36:45 +08:00
parent 15b06bddff
commit 1e2e7c86d0
4 changed files with 17 additions and 7 deletions

View File

@ -35,7 +35,7 @@
android:label="转发规则" />
<activity
android:name="com.idormy.sms.forwarder.SenderActivity"
android:label="发送方设置" />
android:label="发送方" />
<receiver android:name="com.idormy.sms.forwarder.BroadCastReceiver.RebootBroadcastReceiver">
<intent-filter android:priority="2147483647">

View File

@ -5,6 +5,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.idormy.sms.forwarder.R;
@ -61,6 +62,7 @@ public class RuleAdapter extends ArrayAdapter<RuleModel> {
viewHolder = new ViewHolder();
viewHolder.ruleMatch = view.findViewById(R.id.rule_match);
viewHolder.ruleSender = view.findViewById(R.id.rule_sender);
viewHolder.ruleSenderImage = view.findViewById(R.id.rule_sender_image);
// 将ViewHolder存储在View中即将控件的实例存储在其中
view.setTag(viewHolder);
@ -75,10 +77,9 @@ public class RuleAdapter extends ArrayAdapter<RuleModel> {
viewHolder.ruleMatch.setText(ruleModel.getRuleMatch());
if (!senderModel.isEmpty()) {
viewHolder.ruleSender.setText(senderModel.get(0).getName());
viewHolder.ruleSenderImage.setImageResource(senderModel.get(0).getImageId());
} else {
viewHolder.ruleSender.setText("");
}
}
@ -110,6 +111,7 @@ public class RuleAdapter extends ArrayAdapter<RuleModel> {
class ViewHolder {
TextView ruleMatch;
TextView ruleSender;
ImageView ruleSenderImage;
}
}

View File

@ -3,17 +3,24 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/rule_sender_image"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="5dp"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/rule_match"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="10dp" />
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/rule_sender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="10dp" />
android:layout_marginLeft="10dp" />
</LinearLayout>

View File

@ -5,8 +5,9 @@
<ImageView
android:id="@+id/sender_image"
android:layout_width="50dp"
android:layout_height="50dp" />
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="5dp" />
<TextView
android:id="@+id/sender_name"