我已将图像按钮和textView排列成线性布局,我想知道当我在模拟器和手机上运行应用程序时,图像按钮的布局相同,但是它们相距很小,相距太远。
这是我的内容xml文件的内部。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical"
android:weightSum="8"
tools:showIn="@layout/activity_emotions"
tools:context="com.example.chadymaebarinan.emoji_express.Needs"
android:background="@drawable/backgroundnew">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="5"
android:orientation="vertical">
<ImageView
android:layout_weight="4"
android:layout_width="100dp"
android:layout_height="70dp"
android:src="@drawable/kid"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ME"
android:textSize="20sp"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="11"
android:weightSum="6"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonAngry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/angrybutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonHappy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/happybutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:id="@+id/buttonSad"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/sadbutton"
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Angry"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sad"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="@+id/buttonPainful"
android:src="@drawable/painfulbutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonScared"
android:scaleType="fitCenter"
android:src="@drawable/scaredbutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonInLove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/inlovebutton"
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Painful"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scared"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="In Love"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:weightSum="3"
android:orientation="horizontal"
android:padding="10dp">
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonTired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/tiredbutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonEmbarrased"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/embarrasedbutton"
android:background="@null"/>
<ImageButton
android:layout_weight="1"
android:id="@+id/buttonConfused"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/confusedbutton"
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:weightSum="3"
android:orientation="horizontal">
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tired"
android:gravity="center" />
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Embarrased"
android:gravity="center"/>
<TextView
android:padding="10dp"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Confused"
android:gravity="center"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
谢谢你们的帮助。 :)
答案 0 :(得分:1)
希望这种方法可以帮助您:
print df.set_index('value').stack().drop_duplicates().unstack().reset_index()
value p1 p2
0 1 a b
1 2 None c
2 3 None d