android制作评价界面

制作一个评价界面
话不多说,先上效果图
在这里插入图片描述
首先先看看界面设计,本人采用的是垂直线性布局,通过多个水平线性布局的引入来完成位置设置,通过android layout_weight="?"来设置,其中?表示比例(整形)
界面中要设置一张用户图片(ImageView),和输入框EditText,其次,是ImageButton图片按钮当点击它时跳转到相册,这里就不演示了(Intent至关重要),请各位记得加入uri权限
最后几个星级评分条CheckBox复选框,和Button按钮进行点击事件
上代码
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context=".MainActivity">
    //orientation是设置方向vertical为垂直,horizontal为水平


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">//水平线性布局,其中,layout_height是要分的比例,通过layout_weight="整形(int)"

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="发表评价"
            android:textSize="45dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            app:srcCompat="@drawable/shangp" />
        //设置图片,一般较为方便的话建议各位拖控件

        <EditText
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:hint="请写下对商品的感受吧,对他人帮助很大!"
            android:textSize="40dp" />
        //输入框,hint是提示文字,注意textSize根据机型自己设置

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:orientation="horizontal">

        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:background="#fff"
            app:srcCompat="@drawable/tup" />
        //设置图片按钮,在background中#111为黑色,#fff为白色,#bbb为灰色,其他颜色可单机左边进行调换

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:orientation="horizontal"></LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:text="团体综合满意度"
            android:textColor="#111"
            android:textSize="40dp" />

        <RatingBar
            android:id="@+id/ratingBar"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginRight="50dp"
            android:numStars="5"
            android:rating="0" />
        //星级评分条,numStars设置有多少颗星星,rating设置默认是由多少星星是选中状态为浮点数,marginRiaht是设置右边间距


    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"
        android:background="#317B7B7C"
        android:orientation="horizontal">

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="店铺评分"
            android:textColor="#111"
            android:textSize="50dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="商家服务诚信度"
            android:textColor="#111"
            android:textSize="40dp" />

        <RatingBar
            android:id="@+id/ratingBar2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="50dp"
            android:numStars="5"
            android:rating="0" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/textView5"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="服务态度"
            android:textColor="#111"
            android:textSize="40dp" />

        <RatingBar
            android:id="@+id/ratingBar3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginRight="50dp"
            android:numStars="5"
            android:rating="0" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2.5"
        android:gravity="center"
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2.5"
            android:text="匿名评价"
            android:textSize="40dp" />
        //复选框

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#DD714D"
            android:text="发表评价"
            android:textColor="#fff"
            android:textSize="30dp" />
    </LinearLayout>
</LinearLayout>

以上已经注释过了,如果还有什么不会的,欢迎提问
另外要注意的是RatingBar(星级评分条)宽度width要设置为自适应(wrap_content)否则星星数量将会不受控制
最后在MainAcitivity.java
RatingBar(星级评分条)设置OnRatingBarChangeListener事件,然后重写下onRatingChanged()方法
其余设置点击事件或进行Activity之间的传递
备注:uri权限为

<!--拍照-->
    <uses-permission android:name="android.permission.CAMERA" />
    <!--读写-->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.PERMISSIONS_STORAGE"/>

祝好!

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是制作登录界面的步骤: 1. 创建一个新项目 打开 Android Studio,点击 "Start a new Android Studio project",然后选择 "Empty Activity",并为项目命名。 2. 设计登录界面 在 "activity_main.xml" 文件中,使用布局文件来设计登录界面。可以使用 LinearLayout、RelativeLayout、ConstraintLayout 等布局来实现。以下是一个简单的登录界面布局: ``` <?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" android:padding="16dp"> <EditText android:id="@+id/username" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Username" /> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Password" android:inputType="textPassword" /> <Button android:id="@+id/login" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" /> </LinearLayout> ``` 3. 在 MainActivity 中添加逻辑 在 MainActivity 中,使用 findViewById() 方法获取布局中的控件,并添加逻辑来处理登录按钮点击事件。以下是一个简单的 MainActivity: ``` public class MainActivity extends AppCompatActivity { private EditText mUsernameEditText; private EditText mPasswordEditText; private Button mLoginButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mUsernameEditText = findViewById(R.id.username); mPasswordEditText = findViewById(R.id.password); mLoginButton = findViewById(R.id.login); mLoginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = mUsernameEditText.getText().toString(); String password = mPasswordEditText.getText().toString(); // TODO: 处理用户登录逻辑 } }); } } ``` 4. 运行应用程序 现在可以运行应用程序,并在登录界面中输入用户名和密码进行登录。 这是一个简单的登录界面制作过程,你可以根据自己的需求进行更改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值