解决LeftScrollView内容宽度设置问题,使用parent.getMeasuredWidth()解决。

This commit is contained in:
ZhanGSKen 2025-04-05 14:21:15 +08:00
parent 029d4193e1
commit 489bc87959
3 changed files with 20 additions and 15 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Sat Apr 05 05:42:35 GMT 2025
#Sat Apr 05 06:19:16 GMT 2025
stageCount=0
libraryProject=
baseVersion=1.0
publishVersion=1.0.0
buildCount=446
buildCount=451
baseBetaVersion=1.0.1

View File

@ -5,12 +5,12 @@ package cc.winboll.studio.positions.adapters;
* @Date 2025/04/04 13:38:13
*/
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@ -217,12 +217,15 @@ public class PostionModelAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public SimpleViewHolder(@NonNull ViewGroup parent, @NonNull View itemView) {
super(itemView);
//LinearLayout linearLayout = itemView.findViewById(R.id.linearLayout);
scrollView = itemView.findViewById(R.id.scrollView);
//tvRuleText = itemView.findViewById(R.id.ruletext_tv);
tvComments = new TextView(itemView.getContext());
//tvComments.setBackgroundColor(Color.GRAY);
LogUtils.d(TAG, String.format("getWidth() %d", parent.getWidth()));
scrollView.setContentWidth(parent.getWidth());
//LogUtils.d(TAG, String.format("linearLayout.getMeasuredWidth() %d", linearLayout.getMeasuredWidth()));
LogUtils.d(TAG, String.format("parent.getMeasuredWidth() %d", parent.getMeasuredWidth()));
scrollView.setContentWidth(parent.getMeasuredWidth());
//scrollView.setContentWidth(600);
scrollView.addContentLayout(tvComments);
}

View File

@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="2dp">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="2dp"
android:id="@+id/linearLayout">
<cc.winboll.studio.positions.views.LeftScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"/>
<cc.winboll.studio.positions.views.LeftScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"/>
</LinearLayout>