//数据接口
String jsonurl = "https://free-api.heweather.net/s6/weather/forecast?location=zhuhai&key=027b47dff09843d2913df44ea8552f76";
String image = "https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture";
public static String loadJson(String url) {
String json = null;
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute();
json = response.body().string();
Log.d("aaa",json);
} catch (IOException e) {
e.printStackTrace();
}
return json;
}
{"HeWeather6":[{"basic":{"cid":"CN101280701","location":"珠海","parent_city":"珠海","admin_area":"广东","cnty":"中国","lat":"22.2249794","lon":"113.5539856","tz":"+8.00"},"update":{"loc":"2020-03-12 16:56","utc":"2020-03-12 08:56"},"status":"ok","daily_forecast":[{"cond_code_d":"300","cond_code_n":"101","cond_txt_d":"阵雨","cond_txt_n":"多云","date":"2020-03-12","hum":"93","mr":"21:24","ms":"08:33","pcpn":"1.0","pop":"55","pres":"1012","sr":"06:35","ss":"18:34","tmp_max":"23","tmp_min":"19","uv_index":"1","vis":"24","wind_deg":"170","wind_dir":"南风","wind_sc":"3-4","wind_spd":"24"},{"cond_code_d":"300","cond_code_n":"300","cond_txt_d":"阵雨","cond_txt_n":"阵雨","date":"2020-03-13","hum":"77","mr":"22:27","ms":"09:17","pcpn":"0.0","pop":"25","pres":"1014","sr":"06:34","ss":"18:34","tmp_max":"24","tmp_min":"17","uv_index":"2","vis":"24","wind_deg":"175","wind_dir":"南风","wind_sc":"3-4","wind_spd":"16"},{"cond_code_d":"101","cond_code_n":"101","cond_txt_d":"多云","cond_txt_n":"多云","date":"2020-03-14","hum":"84","mr":"23:30","ms":"10:02","pcpn":"1.0","pop":"55","pres":"1016","sr":"06:34","ss":"18:35","tmp_max":"23","tmp_min":"17","uv_index":"3","vis":"25","wind_deg":"4","wind_dir":"北风","wind_sc":"3-4","wind_spd":"13"}]}]}
//得到天气预测数据
public static ArrayList<WeatherB> ansJson(String json) {
JsonObject asJsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("HeWeather6").getAsJsonArray();
JsonElement jsonElement = jsonArray.get(0);
JsonObject asJsonObject1 = new JsonParser().parse(String.valueOf(jsonElement)).getAsJsonObject();
JsonArray daily_forecast = asJsonObject1.get("daily_forecast").getAsJsonArray();
String arr = String.valueOf(daily_forecast);
Log.d("aaa",arr);
Gson gson = new Gson();
ArrayList<WeatherB> list = gson.fromJson(arr, new TypeToken<ArrayList<WeatherB>>() {
}.getType());
Log.d("aaa",list.get(0).toString());
return list;
}
//得到地址信息
public static Address ansJsonAddre(String json) {
JsonObject asJsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("HeWeather6").getAsJsonArray();
JsonElement jsonElement = jsonArray.get(0);
JsonObject asJsonObject1 = new JsonParser().parse(String.valueOf(jsonElement)).getAsJsonObject();
JsonObject basic = asJsonObject1.get("basic").getAsJsonObject();
String arr = String.valueOf(basic);
Log.d("aaa",arr);
Gson gson = new Gson();
Address list = gson.fromJson(arr,Address.class);
Log.d("aaa",list.toString());
return list;
}
private void initImage(@NonNull View view) {
// weaRefer.setVisibility(View.INVISIBLE);
weaRefer.setText("刷新中。。。");
weaTime.setText("刷新中。。。");
Glide.with(view.getContext()).load(image).listener(new RequestListener<Drawable>() {
//加载失败的时候调用
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
//加载成功的时候调用
@SuppressLint("SimpleDateFormat")
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
weaRefer.setText("刷新完毕!");
long l = System.currentTimeMillis();
Date date = new Date(l);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = simpleDateFormat.format(date);
weaTime.setText(format);
return false;
}
}).skipMemoryCache(true).
//设置缓存
diskCacheStrategy(DiskCacheStrategy.NONE).into(img);
// weaRefer.setVisibility(View.VISIBLE);
}
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/text_Grey">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="1dp" />
<solid android:color="@color/colorWhite" />
shape>
item>
ripple>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/text_Grey" android:state_pressed="true"/>
<item android:drawable="@color/text_Grey" android:state_focused="true"/>
<item android:drawable="@color/colorWhite"/>
selector>
… 该接口的天气标识图的编码未数字,而drawable资源不能是数字开头所以要处理一下
int id = context.getResources().getIdentifier("s"+list.get(position).cond_code_d,
"drawable", context.getPackageName());
Drawable drawable = context.getResources().getDrawable(id);
holder.listImg.setImageDrawable(drawable);
class MyTask extends AsyncTask<String, Integer, String> {
private final Context context;
private String json;
public MyTask(View view) {
context = view.getContext();
}
@SuppressLint("CheckResult")
@Override
protected String doInBackground(String... strings) {
//加载天气api,返回json数据
json = NetLoad.loadJson(jsonurl);
htmljson = NetLoad.loadJson2(WeatherFragment.this.html);
return null;
}
//更新ui
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//解析json
list = NetLoad.ansJson(json);
addresses = NetLoad.ansJsonAddre(this.json);
weaTianq.setText(list.get(0).cond_txt_d);
weaTiwen.setText("相对湿度:"+list.get(0).hum);
int t = (Integer.parseInt(list.get(0).tmp_max)+Integer.parseInt(list.get(0).tmp_min))/2;
weaWengdu.setText(String.valueOf(t));
weaAdd.setText(addresses.parent_city);
weaDesc.setText(addresses.admin_area+"|"+addresses.cnty);
MyAdapter myAdapter = new MyAdapter(context, list);
weaVp.setAdapter(myAdapter);
}
}
public class WeatherFragment extends SupportFragment {
private TextView weaAdd;
private TextView weaDesc;
private RecyclerView weaVp;
private ConstraintLayout weaConsta;
private TextView weaRefer;
private TextView weaTime;
private TextView weaWengdu;
private TextView weaTiwen;
private TextView weaTianq;
private ImageView img;
private ArrayList<WeatherB> list;
private Address addresses;
private MyTask task;
private ConstraintLayout next;
private String htmljson;
public WeatherFragment() {
// Required empty public constructor
}
String jsonurl = "https://free-api.heweather.net/s6/weather/forecast?location=zhuhai&key=027b47dff09843d2913df44ea8552f76";
String html = "http://139.199.62.53/weather_wb.php";
String image = "https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_weather, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
initfind(view);
task = new MyTask(view);
task.execute();
initImage(view);
myclick();
LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
weaVp.setLayoutManager(layoutManager);
}
class MyTask extends AsyncTask<String, Integer, String> {
private final Context context;
private String json;
public MyTask(View view) {
context = view.getContext();
}
@SuppressLint("CheckResult")
@Override
protected String doInBackground(String... strings) {
//加载网络图片,设置为背景
// NetLoad.loadImage(image);
//加载天气api,返回json数据
json = NetLoad.loadJson(jsonurl);
htmljson = NetLoad.loadJson2(WeatherFragment.this.html);
return null;
}
//更新ui
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//设置图片
// Glide.with(context).load(image).into(img);
//解析json
list = NetLoad.ansJson(json);
addresses = NetLoad.ansJsonAddre(this.json);
weaTianq.setText(list.get(0).cond_txt_d);
weaTiwen.setText("相对湿度:"+list.get(0).hum);
int t = (Integer.parseInt(list.get(0).tmp_max)+Integer.parseInt(list.get(0).tmp_min))/2;
weaWengdu.setText(String.valueOf(t));
weaAdd.setText(addresses.parent_city);
weaDesc.setText(addresses.admin_area+"|"+addresses.cnty);
MyAdapter myAdapter = new MyAdapter(context, list);
weaVp.setAdapter(myAdapter);
}
}
private void initfind(View view) {
weaAdd = view.findViewById(R.id.wea_add);
weaDesc = view.findViewById(R.id.wea_desc);
next = view.findViewById(R.id.wea_next);
weaVp = view.findViewById(R.id.wea_vp);
weaConsta = view.findViewById(R.id.wea_consta);
weaRefer = view.findViewById(R.id.wea_refer);
weaTime = view.findViewById(R.id.wea_time);
weaWengdu = view.findViewById(R.id.wea_wengdu);
weaTiwen = view.findViewById(R.id.wea_tiwen);
weaTianq = view.findViewById(R.id.wea_tianq);
img = view.findViewById(R.id.wea_img);
}
private void myclick() {
//点击监听
weaConsta.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initImage(v);
// task.execute();
}
});
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
bundle.putString("html",htmljson);
Intent intent = new Intent(getContext(),HtmlActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
private void initImage(@NonNull View view) {
// weaRefer.setVisibility(View.INVISIBLE);
weaRefer.setText("刷新中。。。");
weaTime.setText("刷新中。。。");
Glide.with(view.getContext()).load(image).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@SuppressLint("SimpleDateFormat")
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
weaRefer.setText("刷新完毕!");
long l = System.currentTimeMillis();
Date date = new Date(l);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String format = simpleDateFormat.format(date);
weaTime.setText(format);
return false;
}
}).skipMemoryCache(true).
diskCacheStrategy(DiskCacheStrategy.NONE).into(img);
// weaRefer.setVisibility(View.VISIBLE);
}
}
public class NetLoad {
public static String loadJson(String url) {
String json = null;
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute();
json = response.body().string();
Log.d("aaa",json);
} catch (IOException e) {
e.printStackTrace();
}
return json;
}
public static String loadJson2(String url) {
String json = null;
try {
OkHttpClient client = new OkHttpClient();
// Request request = new Request.Builder().url(url).build();
Request.Builder builder = new Request.Builder();
HttpUrl.Builder newBuilder = HttpUrl.parse(url).newBuilder();
newBuilder.addQueryParameter("LOCATION","珠海");
newBuilder.addQueryParameter("ADMIN_AREA","广东");
newBuilder.addQueryParameter("CNTY","中国");
builder.url(newBuilder.build());
Request request = builder.build();
Response response = client.newCall(request).execute();
json = response.body().string();
Log.d("aaa",json);
} catch (IOException e) {
e.printStackTrace();
}
return json;
}
public static void loadImage(String image) {
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(image).build();
Response response = client.newCall(request).execute();
InputStream inputStream = response.body().byteStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
File file = new File(Environment.getExternalStorageDirectory(), "image.jpg");
FileOutputStream fileOutputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG,100,fileOutputStream);
inputStream.close();
Log.d("aaa","加载图片完成");
} catch (IOException e) {
e.printStackTrace();
}
}
public static ArrayList<WeatherB> ansJson(String json) {
JsonObject asJsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("HeWeather6").getAsJsonArray();
JsonElement jsonElement = jsonArray.get(0);
JsonObject asJsonObject1 = new JsonParser().parse(String.valueOf(jsonElement)).getAsJsonObject();
JsonArray daily_forecast = asJsonObject1.get("daily_forecast").getAsJsonArray();
String arr = String.valueOf(daily_forecast);
Log.d("aaa",arr);
Gson gson = new Gson();
ArrayList<WeatherB> list = gson.fromJson(arr, new TypeToken<ArrayList<WeatherB>>() {
}.getType());
Log.d("aaa",list.get(0).toString());
return list;
}
public static Address ansJsonAddre(String json) {
JsonObject asJsonObject = new JsonParser().parse(json).getAsJsonObject();
JsonArray jsonArray = asJsonObject.get("HeWeather6").getAsJsonArray();
JsonElement jsonElement = jsonArray.get(0);
JsonObject asJsonObject1 = new JsonParser().parse(String.valueOf(jsonElement)).getAsJsonObject();
JsonObject basic = asJsonObject1.get("basic").getAsJsonObject();
String arr = String.valueOf(basic);
Log.d("aaa",arr);
Gson gson = new Gson();
Address list = gson.fromJson(arr,Address.class);
Log.d("aaa",list.toString());
return list;
}
public static String converDateFormat(String string){
Date date = null;
try {
date= new SimpleDateFormat("yyyy-MM-dd").parse(string);
} catch (ParseException e) {
e.printStackTrace();
}
String s = new SimpleDateFormat("MM/dd").format(date);
return s;
}
}
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyHolder> {
Context context;
ArrayList<WeatherB> list;
public MyAdapter(Context context, ArrayList<WeatherB> list) {
this.context = context;
this.list = list;
}
@NonNull
@Override
public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new MyHolder(LayoutInflater.from(parent.getContext()).
inflate(R.layout.list_re,parent,false));
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull MyHolder holder, int position) {
String date = list.get(position).date;
String s = NetLoad.converDateFormat(date);
holder.listDay.setText(s);
holder.listDesc.setText(list.get(position).cond_txt_d);
holder.listWd.setText(list.get(position).tmp_max+"|"+list.get(position).tmp_min);
// holder.listImg.setImageDrawable();
int id = context.getResources().getIdentifier("s"+list.get(position).cond_code_d,
"drawable", context.getPackageName());
Drawable drawable = context.getResources().getDrawable(id);
holder.listImg.setImageDrawable(drawable);
}
@Override
public int getItemCount() {
return list.size();
}
class MyHolder extends RecyclerView.ViewHolder {
TextView listDay;
ImageView listImg;
TextView listDesc;
TextView listWd;
public MyHolder(@NonNull View itemView) {
super(itemView);
listDay = (TextView) itemView.findViewById(R.id.list_day);
listImg = (ImageView) itemView.findViewById(R.id.list_img);
listDesc = (TextView) itemView.findViewById(R.id.list_desc);
listWd = (TextView) itemView.findViewById(R.id.list_wd);
}
}
}
public class WeatherB {
public String cond_code_d;
public String cond_txt_d;
public String date;
public String hum;
public String tmp_max;
public String tmp_min;
}
public class Address {
public String parent_city;
public String admin_area;
public String cnty;
}
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.WeatherFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.62" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/wea_vp"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/wea_consta"
android:layout_width="0dp"
android:background="@drawable/water_selector"
android:clickable="true"
android:focusable="true"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/wea_img"
android:layout_width="0dp"
android:scaleType="fitXY"
android:layout_height="0dp"
android:alpha="0.8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<TextView
android:id="@+id/wea_refer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/wea_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/wea_wengdu"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="16dp"
android:text="26"
android:textSize="50sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:text="o"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="@+id/wea_wengdu"
app:layout_constraintTop_toTopOf="@+id/wea_wengdu" />
<TextView
android:id="@+id/wea_tiwen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="TextView"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.33"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/wea_tianq"
android:layout_width="wrap_content"
android:textColor="#000000"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="TextView"
app:layout_constraintBottom_toTopOf="@+id/wea_tiwen"
app:layout_constraintStart_toStartOf="@+id/wea_tiwen" />
androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/wea_next"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/water_selector"
android:clickable="true"
android:focusable="true"
app:layout_constraintBottom_toTopOf="@+id/wea_vp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline">
<TextView
android:id="@+id/wea_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.15"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/wea_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
androidx.constraintlayout.widget.ConstraintLayout>
androidx.constraintlayout.widget.ConstraintLayout>
FrameLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@drawable/water_selector"
android:clickable="true"
android:focusable="true"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:gravity="center"
android:id="@+id/list_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.02"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/list_img"
android:layout_width="61dp"
android:layout_height="62dp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.34"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.499"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/list_desc"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/list_wd"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.96"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
androidx.constraintlayout.widget.ConstraintLayout>
LinearLayout>