基于Android的本地电子书阅读器的设计与实现Ebook(1)

基于Android的本地电子书阅读器的设计与实现Ebook(1)

学习Android时间不久,试着做了一个本地电子书阅读器APP,因为知识浅薄并不能像其他大佬一样实现各种繁杂的功能,但可以实现基本的阅读和记录读后感功能,尝试写一篇csdn聊以自慰。

开始前先展示一下我的阅读器APP图标:
请添加图片描述
现在进入我们进入正文,要想快速了解这个app,我们需要知道她的一些关键文件目录下的名称:
assets:请添加图片描述
java:请添加图片描述
res:请添加图片描述
其中assets和menu是原来目录没有的,需要自己创建。

然后我们点开Ebook,映入眼帘的是一个登录界面:请添加图片描述
对应的布局文件名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"
    android:padding="15dp"
    tools:context=".MainActivity"
    android:background="@drawable/rebg">

    <EditText
        android:id="@+id/main_et_account"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="160dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:hint="请输入您的用户名"
        android:inputType="textPersonName" />

    <EditText
        android:id="@+id/main_et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:hint="请输入您的密码"
        android:inputType="textPassword" />

    <Button
        android:id="@+id/main_btn_register"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:layout_marginRight="80dp"
        android:layout_marginLeft="80dp"
        android:background="@drawable/shape1"
        android:text="注   册"
        android:textColor="@color/black"
        android:textSize="30dp"
        android:textStyle="normal"/>

    <Button
        android:id="@+id/main_btn_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:layout_marginRight="80dp"
        android:layout_marginLeft="80dp"
        android:background="@drawable/shape1"
        android:text="登录"
        android:textColor="@color/black"
        android:textSize="30dp"
        android:textStyle="normal" />

</LinearLayout>

这里解释一下,如果想要让按键不是原来的方方正正的,要在drawable创建一个XML文件具体如下:
shape1

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <corners android:radius="40dip">
    </corners>
    <padding
        android:bottom="5dp"
        android:left="10dp"
        android:right="10dp"
        android:top="5dp" />
    <solid android:color="@color/teal_200"/>
</shape>

对应的java名称MainActivity:

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
   
    //变量名注册
    private EditText myAccount;
    private EditText myPassword;
    private Button myRegisterBtn;
    private Button myLoginBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //注册ID
        myAccount = findViewById(R.id.main_et_account);
        myPassword = findViewById(R.id.main_et_password);
        myRegisterBtn = findViewById(
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

睨箐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值