Kakao i Connect Live 커뮤니티

PercentFrameLayout 문의

어플을 개발하는데 화면을 “응” 이런 모양으로 2분할 할려고
percentFrameLayout.setPosition() 써서 개발을 진행했습니다.

여기서 추가로 버튼을 누르면 화면이 가로 3분할로 이루어 질 수 있도록 할려고 하고 있는데
setPosition은 처음 한번밖에 코드가 안먹혀서 문의합니다.
PercentFrameLayout을 사용하여 동적으로 화면을 3분할 할 수 있는 방법이 있을까요?

1 Like

안녕하세요^^
setPosition은 횟수와 상관 없이 계속 적용이 되는 기능입니다.

코드와 함께 문의를 주시면 좀더
답변을 드릴 수 있을듯 합니다.

감사합니다.

빠른 답변 감사드립니다. 코드로 물어보는게 빨랐네요.
아래에 보다싶이 화면은 Ralative안에 레이아웃이 3개고
한개는 컨텐츠 영역,나머지는 local, remote 영역입니다.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="#FFFFFF"
    tools:context=".MainActivity">

    <com.remotemonster.sdk.PercentFrameLayout
        android:id="@+id/remotePercentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <org.webrtc.SurfaceViewRenderer
            android:background="#FFFF00"
            android:id="@+id/remoteRender"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </com.remotemonster.sdk.PercentFrameLayout>

    <com.remotemonster.sdk.PercentFrameLayout
        android:id="@+id/localPercentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <org.webrtc.SurfaceViewRenderer
            android:background="#FF00FF"
            android:id="@+id/localRender"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </com.remotemonster.sdk.PercentFrameLayout>


    <FrameLayout
        android:alpha="0.5"
        android:id="@+id/contentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <Button
            android:id="@+id/button_divide"
            android:text="divide"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>
</RelativeLayout>


public class MainActivity extends AppCompatActivity {

    private PercentFrameLayout localPercentFrame, remotePercentFrame;
    private SurfaceViewRenderer localRender, remoteRender;
    private Button button;
    public void initListener() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setThirdDivide();
            }
        });
    }

    public void setBinaryDivide(){
        remotePercentFrame.setPosition(0, 0, 100, 50);
        localPercentFrame.setPosition(0, 50, 100, 50);
    }

    public void setThirdDivide(){
        remotePercentFrame.setPosition(50, 50, 50, 50);
        localPercentFrame.setPosition(0, 50, 50, 50);
    }

    public void initUI() {
        localPercentFrame = findViewById(R.id.localPercentFrame);
        remotePercentFrame = findViewById(R.id.remotePercentFrame);
        localRender = findViewById(R.id.localRender);
        remoteRender = findViewById(R.id.remoteRender);
        button = findViewById(R.id.button_divide);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initUI();
        initListener();
        setBinaryDivide();
    }
}

버튼을 누르게 되면 local과 remote를 50%크기로 좌측과 우측에 ㅜ 모양으로 화면을 분할 할려고 이런식으로 짯는데 setPosition이 작동이 안되는것 같아요. ㅠㅠ

혹시 모르니 아래에 로그도 같이 남깁니다.
06-05 14:56:08.027 15369-15387/com.okiwi.project.lallylayoutinflate D/OpenGLRenderer: HWUI GL Pipeline
06-05 14:56:08.033 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: setView = DecorView@e73827f[MainActivity] TM=true MM=false
06-05 14:56:08.057 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: dispatchAttachedToWindow
06-05 14:56:08.064 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceViewRenderer: localRender: onMeasure(). New size: 1440x1072
SurfaceViewRenderer: remoteRender: onMeasure(). New size: 1440x1072
06-05 14:56:08.065 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceViewRenderer: localRender: onMeasure(). New size: 1440x1072
SurfaceViewRenderer: remoteRender: onMeasure(). New size: 1440x1072
06-05 14:56:08.075 15369-15369/com.okiwi.project.lallylayoutinflate V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
06-05 14:56:08.076 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: Relayout returned: old=[0,0][0,0] new=[0,0][1440,2560] result=0x7 surface={valid=true 484351848448} changed=true
06-05 14:56:08.083 15369-15387/com.okiwi.project.lallylayoutinflate I/OpenGLRenderer: Initialized EGL, version 1.4
06-05 14:56:08.083 15369-15387/com.okiwi.project.lallylayoutinflate D/OpenGLRenderer: Swap behavior 2
06-05 14:56:08.087 15369-15387/com.okiwi.project.lallylayoutinflate D/libGLESv1: STS_GLApi : DTS, ODTC are not allowed for Package : com.okiwi.project.lallylayoutinflate
06-05 14:56:08.087 15369-15387/com.okiwi.project.lallylayoutinflate D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000, [1440x2560]-format:1
06-05 14:56:08.087 15369-15387/com.okiwi.project.lallylayoutinflate D/OpenGLRenderer: eglCreateWindowSurface = 0x70bac1d8c0
06-05 14:56:08.088 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceViewRenderer: localRender: onMeasure(). New size: 1440x1120
SurfaceViewRenderer: remoteRender: onMeasure(). New size: 1440x1120
SurfaceViewRenderer: localRender: onMeasure(). New size: 1440x1120
06-05 14:56:08.089 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceViewRenderer: remoteRender: onMeasure(). New size: 1440x1120
06-05 14:56:08.090 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: EglRenderer: remoteRendersetLayoutAspectRatio: 1.2857143
EglRenderer: localRendersetLayoutAspectRatio: 1.2857143
06-05 14:56:08.095 15369-15369/com.okiwi.project.lallylayoutinflate D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.okiwi.project.lallylayoutinflate/com.okiwi.project.lallylayoutinflate.MainActivity@a87afaa@0) org.webrtc.SurfaceViewRenderer{a87afaa V.E… …ID 0,0-1440,1120 #7f070058 app:id/remoteRender}
06-05 14:56:08.097 15369-15369/com.okiwi.project.lallylayoutinflate V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
06-05 14:56:08.097 15369-15369/com.okiwi.project.lallylayoutinflate D/SurfaceView: surfaceCreated 2 org.webrtc.SurfaceViewRenderer{a87afaa V.E… …ID 0,0-1440,1120 #7f070058 app:id/remoteRender}
surfaceChanged (1440,1120) 2 org.webrtc.SurfaceViewRenderer{a87afaa V.E… …ID 0,0-1440,1120 #7f070058 app:id/remoteRender}
06-05 14:56:08.098 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceEglRenderer: remoteRender: surfaceChanged: format: 4 size: 1440x1120
06-05 14:56:08.100 15369-15369/com.okiwi.project.lallylayoutinflate D/SurfaceView: BG show() Surface(name=Background for - SurfaceView - com.okiwi.project.lallylayoutinflate/com.okiwi.project.lallylayoutinflate.MainActivity@ac7c79b@0) org.webrtc.SurfaceViewRenderer{ac7c79b V.E… …ID 0,1120-1440,2240 #7f070046 app:id/localRender}
06-05 14:56:08.113 15369-15369/com.okiwi.project.lallylayoutinflate V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
06-05 14:56:08.114 15369-15369/com.okiwi.project.lallylayoutinflate D/SurfaceView: surfaceCreated 2 org.webrtc.SurfaceViewRenderer{ac7c79b V.E… …ID 0,1120-1440,2240 #7f070046 app:id/localRender}
surfaceChanged (1440,1120) 2 org.webrtc.SurfaceViewRenderer{ac7c79b V.E… …ID 0,1120-1440,2240 #7f070046 app:id/localRender}
06-05 14:56:08.114 15369-15369/com.okiwi.project.lallylayoutinflate I/org.webrtc.Logging: SurfaceEglRenderer: localRender: surfaceChanged: format: 4 size: 1440x1120
06-05 14:56:08.130 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: Relayout returned: old=[0,0][1440,2560] new=[0,0][1440,2560] result=0x3 surface={valid=true 484351848448} changed=false
06-05 14:56:08.159 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1440, 2560) ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
MSG_WINDOW_FOCUS_CHANGED 1
06-05 14:56:08.163 15369-15369/com.okiwi.project.lallylayoutinflate V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@3f63311 nm : com.okiwi.project.lallylayoutinflate ic=null
06-05 14:56:08.163 15369-15369/com.okiwi.project.lallylayoutinflate I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
06-05 14:56:08.176 15369-15369/com.okiwi.project.lallylayoutinflate V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@3891c76 nm : com.okiwi.project.lallylayoutinflate ic=null
06-05 14:56:56.175 15369-15369/com.okiwi.project.lallylayoutinflate

//######이 아랫 부분이 클릭했을 Button을 클릭했을때의 로깅입니다.

D/ViewRootImpl@89bb79e[MainActivity]: ViewPostIme pointer 0
06-05 14:56:56.251 15369-15369/com.okiwi.project.lallylayoutinflate D/ViewRootImpl@89bb79e[MainActivity]: ViewPostIme pointer 1

다음 아래는 project 스펙입니다.
compileSdkVersion 27
defaultConfig {
applicationId “com.okiwi.project.lallylayoutinflate”
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName “1.0”
multiDexEnabled true
renderscriptSupportModeEnabled true
testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}

dependencies {
implementation fileTree(dir: ‘libs’, include: [’*.jar’])
implementation ‘com.android.support:appcompat-v7:27.0.2’
implementation ‘com.android.support.constraint:constraint-layout:1.1.3’
testImplementation ‘junit:junit:4.12’
androidTestImplementation ‘com.android.support.test:runner:1.0.2’
androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2’
implementation ‘com.remotemonster:sdk:2.2.14’
implementation ‘com.android.support:multidex:1.0.1’
}

보내주신 코드상으로는 이상이 없어 보입니다.

메일로 실행가능한 큰범위의 소스코드를 전달주시거나,
연락처를 전달 부탁드립니다.

메일주소 : [email protected]

감사합니다.

말씀하신 메일 주소로 프로젝트 전체(소스코드 전체)와 해당 소스의 프로그램을 보내드립니다.