Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textview #39

Open
swjung703 opened this issue Feb 6, 2017 · 8 comments
Open

textview #39

swjung703 opened this issue Feb 6, 2017 · 8 comments

Comments

@swjung703
Copy link

wrapcontent_direction, movesiblings, resizesurrounded를
xml단에서 적용 시킨후 텍스트를 쓰고나고 그 레이아웃은 고정한채 더 늘어나거나 하지 않도록 고정해버릴순 없나요..?

@ssomai
Copy link
Owner

ssomai commented Feb 7, 2017

혹시 샘플 소스를 보내주실 수 있을까요? ㅠㅠ

@swjung703
Copy link
Author

swjung703 commented Feb 7, 2017

문제가 발생하는 부분이
RecyclerView에 ScalableLayout을 입히는 과정에서 생기고 있습니다.

Layout은 이렇게되고

ScalableLayout을 감싸는 Linear가 잇는데 짤려서 보여지네요... ㅠ_ㅠ

<com.ssomai.android.scalablelayout.ScalableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    sl:scale_base_height="505"
    sl:scale_base_width="480">

    // 테두리
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/gray_square_box"
        sl:scale_height="467"
        sl:scale_left="12"
        sl:scale_top="18"
        sl:scale_width="456" />

    // 유저 프로필
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        sl:scale_height="33"
        sl:scale_left="24"
        sl:scale_top="30"
        sl:scale_width="33" />

    // 유저 닉네임
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center|start"
        android:includeFontPadding="false"
        android:textColor="#707070"
        sl:scale_height="17"
        sl:scale_left="66"
        sl:scale_textsize="15"
        sl:scale_top="37"
        sl:scale_width="200" />

    // 게시글 날짜
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center|end"
        android:includeFontPadding="false"
        android:textColor="#D1D2D3"
        sl:scale_height="13"
        sl:scale_left="406"
        sl:scale_textsize="12"
        sl:scale_top="40"
        sl:scale_width="50" />

    // 메인 이미지
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        sl:scale_height="260"
        sl:scale_left="0"
        sl:scale_top="73"
        sl:scale_width="480" />

    // 제목
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center|start"
        android:includeFontPadding="false"
        android:lineSpacingExtra="2dp"
        android:maxLines="3"
        android:textColor="#707070"
        sl:scale_height="17"
        sl:scale_left="24"
        sl:scale_textsize="16"
        sl:scale_top="351"
        sl:scale_width="432"
        sl:textview_wrapcontent_direction="bottom"
        sl:textview_wrapcontent_movesiblings="true"
        sl:textview_wrapcontent_resizesurrounded="true" />

    // 해쉬태그
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center|start"
        android:includeFontPadding="false"
        android:lineSpacingExtra="0dp"
        android:maxLines="2"
        android:textColor="#858585"
        sl:scale_height="17"
        sl:scale_left="24"
        sl:scale_textsize="15"
        sl:scale_top="384"
        sl:scale_width="432"
        sl:textview_wrapcontent_direction="bottom"
        sl:textview_wrapcontent_movesiblings="true"
        sl:textview_wrapcontent_resizesurrounded="true" />
</com.ssomai.android.scalablelayout.ScalableLayout>

RecyclerViewAdapter의 onBindViewHolder는 이렇게 되어있습니다.

@OverRide
public void onBindViewHolder(RecyclerViewAdapter.ViewHolder holder, final int position) {
try {
JSONObject object = mDataset.getJSONObject(position);

        holder.userProfileImageView.setImageBitmap(userProfile);
        holder.userNicknameTextView.setText(userNickname);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = format.parse(object.getString("post_date"));
        TimeGapParser timeGapParser = new TimeGapParser();
        holder.dateTextView.setText(timeGapParser.calculateTime(date));

        if (!object.getString("thumbnail_path").equals("null")) {
            holder.Container.setScaleSize(480, 505);
            holder.firstImageView.setVisibility(View.VISIBLE);
            holder.Container.moveChildView(holder.Container.getChildAt(0), 12, 18, 456, 467);
            holder.Container.moveChildView(holder.Container.getChildAt(5), 24, 351);
            holder.Container.moveChildView(holder.Container.getChildAt(6), 24, 384);

            byte[] bytePlainOrg = Base64.decode(object.getString("encodedimage"), 0);
            ByteArrayInputStream inStream = new ByteArrayInputStream(bytePlainOrg);
            holder.firstImageView.setImageBitmap(BitmapFactory.decodeStream(inStream));
        } else {
            holder.Container.setScaleSize(480, 245);
            holder.firstImageView.setVisibility(View.GONE);
            holder.Container.moveChildView(holder.Container.getChildAt(0), 12, 18, 456, 207);
            holder.Container.moveChildView(holder.Container.getChildAt(5), 24, 91);
            holder.Container.moveChildView(holder.Container.getChildAt(6), 24, 124);
            
        }
        holder.titleTextView.setText(object.getString("content"));
        holder.hashtagTextView.setText(object.getString("hashtag"));

        holder.etcImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickListener.etcButtonOnClick(v, position);
            }
        });
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

이렇게 되어있습니다. 문제는 리사이클러뷰에서 아이템이 많아 위아래로 스크롤을 하게 될 경우
메인 이미지와 제목 사이에 공백이 늘어나거나 제목와 태그사이에 공백이 줄어들게 됩니다.

@swjung703
Copy link
Author

swjung703 commented Feb 7, 2017

이미지와 제목 사이에 생기는 공간은 이미지 아래부분이 짤려서 공백이 생기는것으로 보입니다 ㅠㅠㅠㅠ 어쩔때는 제목이랑 부제목이 반정도 겹쳐져서 나올때도 있어요

@ssomai
Copy link
Owner

ssomai commented Feb 9, 2017

움... 어렵네요 ㅠㅠ
혹시 catch 직전에
holder.Container.requestLayout();
holder.Container.forceLayout();
넣어서 한번 테스트해봐주시겠어요?

@juniair
Copy link

juniair commented Feb 9, 2017

저도 이 문제로 혹시나해서 다음과 같이 테스트를 하고 로그를 찍어 봤습니다.

      <com.ssomai.android.scalablelayout.ScalableLayout
        android:id="@+id/scl_content_parent_layout"
        tools:ignore="MissingPrefix"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        app:scale_base_width="1080"
        app:scale_base_height="256"
        android:layout_below="@+id/scalableLayout"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="16dp">

        <com.ssomai.android.scalablelayout.ScalableLayout
            android:id="@+id/scl_content_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:scale_base_width="96"
            app:scale_base_height="60"
            app:scale_width="96"
            app:scale_height="60"
            app:scale_left="255"
            app:scale_top="162"
            android:background="#4D318EF7">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:gravity="center_vertical"
                app:scale_width="1"
                app:scale_height="60"
                app:scale_left="18"
                android:text="9"
                app:scale_textsize="40"
                app:textview_wrapcontent_direction="right"
                />
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:scale_width="32"
                app:scale_height="60"
                app:scale_left="29"
                android:src="@drawable/icon_tpw"/>
        </com.ssomai.android.scalablelayout.ScalableLayout>

    int 가격 = (int)(Math.random()*1000);
    ((TextView) mContentLayout.getChildAt(0)).setText(가격+"");
    float 가격표길이 = mContentLayout.getChildLayoutParams(mContentLayout.getChildAt(0)).getScale_Width()
            + mContentLayout.getChildLayoutParams(mContentLayout.getChildAt(0)).getScale_Left() + 32f + 16f;
    mContentLayout.setScaleWidth(가격표길이);
    mContentParentLayout.getChildLayoutParams(mContentParentLayout.getChildAt(0)).setScale_Width(가격표길이);
    Log.d("TAG 가격표길이", 가격표길이+"");
    Log.d("TAG 부모", mContentParentLayout.getChildLayoutParams(mContentParentLayout.getChildAt(0)).getScale_Width()+"");
    Log.d("TAG 본인", mContentLayout.getScaleWidth()+"");

02-09 09:48:02.624 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 보이스 드라마
02-09 09:48:02.624 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 0b07b870 ( 0.000, 0.000) ( 1.000, 46.000)
02-09 09:48:02.624 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 67.0
02-09 09:48:02.624 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 67.0
02-09 09:48:02.624 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 67.0
02-09 09:48:02.667 20388-20425/com.mimo.scalablelayouttestapp W/EGL_emulation: eglSurfaceAttrib not implemented
02-09 09:48:02.667 20388-20425/com.mimo.scalablelayouttestapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa114b160, error=EGL_SUCCESS
02-09 09:48:02.765 20388-20425/com.mimo.scalablelayouttestapp E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaaa7dcc0
02-09 09:48:02.774 20388-20425/com.mimo.scalablelayouttestapp D/OpenGLRenderer: endAllStagingAnimators on 0xa09eb680 (RippleDrawable) with handle 0xa18155b0
02-09 09:48:05.897 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:05.897 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:05.897 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 67.0
02-09 09:48:05.897 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 67.0
02-09 09:48:05.898 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:05.898 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:05.899 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.114 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:06.114 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.114 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.114 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.116 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.116 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.116 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.258 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:06.258 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.258 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.258 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.259 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.259 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.259 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.442 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:06.442 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.442 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.442 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.443 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.443 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.443 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.626 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:06.826 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.058 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:07.058 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.058 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.058 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.059 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.059 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.059 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.266 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:07.266 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.266 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.266 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.267 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.267 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.267 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.516 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG: 버튼 누름
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG 텍스트 scale_width: 145.88869
02-09 09:48:07.723 20388-20388/com.mimo.scalablelayouttestapp D/TAG 부모: 145.88869
02-09 09:48:07.724 20388-20388/com.mimo.scalablelayouttestapp D/TAG 본인: 145.88869

@swjung703
Copy link
Author

swjung703 commented Feb 9, 2017

넣어보았지만 같은 현상이 발생합니다!
holder.setIsRecyclable(false);를 넣으면 해결은 레이아웃측면은 해결이 됩니다만...
전체에 전부 다 걸어줘야 되다보니... ㅠㅠㅠ ( RecyclerView의 의미가 없어져버리는... ㅠㅠㅠ)
그리고 어떤 경우에는 textview maxline 을 3으로 설정해 놓아도 위아래로 스크롤 하다보면
한줄밖에 나오지 않는 현상도 추가로 나타났습니다.(영역은 늘어나지않음)

@ssomai
Copy link
Owner

ssomai commented Feb 10, 2017

ㅠㅠㅠ 어렵네요. 제가 재연을 해볼려고 해도 잘 안되구...
혹시 가능하시다면 현재 소스나 테스트용 소스를 제 개인 이메일로 보내주실 수 있을까요?
보안은 확실히 지키겠습니다.
ssomai@gmail.com 입니다~.

@swjung703
Copy link
Author

감사합니다 내일중으로 보내겠습니다! ㅠ_ㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants