【发布时间】:2015-03-31 20:05:03
【问题描述】:
我正在尝试制作一个如下所示的绘画应用程序:
所以当用户将手放在表面视图中时,用户将能够在表面视图内绘制线条。 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paint"
android:layout_marginTop="10sp"
android:layout_marginLeft="5sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="3" />
<TextView
android:id="@+id/textV"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_marginTop="20dip"
android:layout_toRightOf="@+id/ivImage"
android:text="User Name"
/>
<ImageView
android:id="@+id/ivImage"
android:layout_width="50dp"
android:layout_height="match_parent"
android:src="@drawable/person"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="20sp">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Assets Models"
android:gravity="center"/>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:drawableLeft="@drawable/ic_launcher"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
<SurfaceView
android:id="@+id/surfaceView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="right" >
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Assets Models" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_launcher"
android:text="Button" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
有谁知道如何使用表面视图或已在 xml 文件中定义的视图而不是动态方式,因此我可以将这些额外的元素(例如按钮、滚动、用户名和图像)放在同一个活动中。 我真的很感激任何帮助。 谢谢
【问题讨论】:
标签: android android-layout drawing paint surfaceview