안녕하세요 저는 카메라 앱을 만들고 있는데 첫 활동은 snapchat과 비슷합니다.android app 버튼과 같은 snapchat 만들기
나는 android camera dev 튜토리얼 (https://developer.android.com/guide/topics/media/camera.html)을 따라 갔다.
하지만 불행히도 원하는 특정 유형의 단추 (단추와 같은 스냅인)는 다루지 않았습니다.
스냅인과 같은 버튼이 있어야합니다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_vertical|center_horizontal"
android:text="capture" />
</FrameLayout>
</LinearLayout>
그리고 내 mainactivity 자바 :
여기에 내 현재의 뷰 XML의 나는, 튜토리얼 추가 한 XML 레이아웃 렌더링 후에서 문제 줄기를 생각
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
// Create an instance of Camera
mCamera = getCameraInstance(getApplicationContext());
// Create our Preview view and set it as the content of our activity.
mPreview = new CameraPreview(this, mCamera);
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);
// Add a listener to the Capture button
Button captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// get an image from the camera
mCamera.takePicture(null, null, mPicture);
}
});
}
preview.addView(mPreview);
카메라 미리보기가 단추 위에 그려져 있다고 생각하는 레이아웃을 오버하십시오.
저는이 문제에 대한 두 가지 해결책만을 생각했습니다.
하나는 프로그래밍 방식으로 preview.addView (mPreview) 뒤에 버튼을 추가합니다. 선. 또는 버튼에 대한 XML 코드에서 설정할 수있는 Z- 인덱스가 있다면?
스냅 샷 버튼은 이미지 버튼입니까? 내 전반적인 질문은 snapchat 앱과 같은 버튼을 만드는 방법입니다.
감사합니다.
같은 당김과 일을 뭔가 [이] (http://stackoverflow.com/questions/6759036/how-to-send-을 만드는 것이 좋습니다 버튼이 반투명 만들기에 관해서는
view-to-back-how-to-control-z-order- 프로그래밍 방식으로) – Ayoub
나 ViewGroup.bringChildToFront();를 사용할 수있는 합리적인 해결책 인 것 같습니다. – Ayoub