java - 浏览屏幕 android 开发

标签 java android navigation

您好,只是想知道是否有人可以帮助我,我是 JAVA(android 开发编程)的新手,完成了一些 HTML 和 C# 的工作。我最近 决定创建一个应用程序,但不知道如何浏览屏幕、主屏幕到练习等。大约有30个屏幕 应用程序内的(页面)每个页面都描述了一个包含图像的练习。我想知道完成这项杂务的最佳方法是什么? 我创建了 2 个 XML 文件,如下所示。

Activity_main.xml

    <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"
        android:background="#808080"
        android:orientation="vertical"
        tools:context=".MainActivity" >

       <TextView
            android:id="@+id/title"
            android:layout_width="184dp"
            android:layout_height="65dp"
            android:layout_marginLeft="40dp"
            android:layout_marginTop="0dp"
            android:gravity="center"
            android:text="@string/description"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#FFFF00"
            android:textSize="26sp" />

        <ImageView
            android:id="@+id/exercise"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="40dp"
            android:src="@drawable/exercises"
            android:clickable="true"
            android:onClick="myClickHandler" />

        <ImageView
            android:id="@+id/routines"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="22dp"
            android:src="@drawable/routines" />

        <ImageView
            android:id="@+id/logbook"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="22dp"
            android:src="@drawable/logbook" />

        <ImageView
            android:id="@+id/qrscanner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="22dp"
            android:src="@drawable/qrscanner" />

        <TextView
            android:id="@+id/Copyright"
            android:layout_width="206dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="220dp"
            android:layout_marginTop="70dp"
            android:text="@string/copyright"
            android:textColor="#FFFF00"
            android:textSize="14sp" />


        <ImageView
            android:id="@+id/Logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="230dp"
            android:layout_marginTop="-440dp"
            android:src="@drawable/logov2" />

    </LinearLayout>

还有一个exercise.xml

    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="452dp"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/Logo"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:layout_marginLeft="230dp"
        android:layout_marginTop="0dp"
        android:src="@drawable/logov2" />

     <ImageView
         android:id="@+id/chest"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginLeft="12dp"
         android:layout_marginTop="30dp"
         android:src="@drawable/chest_exercises" />

     <ImageView
        android:id="@+id/shoulder"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/shoulderexercises" />

         <ImageView
        android:id="@+id/back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="230dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/backexercises" />

        <ImageView
        android:id="@+id/bicep"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/bicepexercises" />

        <ImageView
        android:id="@+id/tricep"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/tricepexercises" />


       <ImageView
        android:id="@+id/abbs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="230dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/abbsexercises" />

        <ImageView
        android:id="@+id/quad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/quadexercise" />

        <ImageView
        android:id="@+id/calves"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/calvesexercises" />

         <ImageView
        android:id="@+id/glutes"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="230dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/gluteexercises" />

        <ImageView
        android:id="@+id/hamstring"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="12dp"
        android:layout_marginTop="20dp"
        android:src="@drawable/hamstringexercises" />


        <ImageView
        android:id="@+id/traps"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="-82dp"
        android:src="@drawable/trapexercises" />

        <TextView
        android:id="@+id/title"
        android:layout_width="184dp"
        android:layout_height="65dp"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="-470dp"
        android:gravity="center"
        android:text="@string/musclegroup"
        android:textColor="#FFFF00"
        android:textSize="26sp" />
    </LinearLayout>
</ScrollView>

我只是想知道如何从主屏幕导航到exercise.xml? 如果我使用 imageviews 作为按钮可以吗?

提前致谢 瑞安

最佳答案

我建议使用按钮并将图像设置为背景。在识别触摸时,图像有时会很糟糕。
因此,导航将是主屏幕 -> 单击锻炼图像 -> 单击 body 部位 -> 查看练习?
对于这么多的项目,仅图像/按钮就完全没问题,但如果您的子菜单变得更大,您应该开始考虑 ListViews 来提高性能。
如果您有这样的层次结构,您可以为每个新屏幕执行一个新 Activity ,或者使用 fragment 。当您浏览屏幕时, fragment 会更流畅,但具有清晰的层次结构,我建议从 Activity 开始。
Activity 不允许您保持恒定的选项卡栏,因为您将真正交换整个屏幕,但如果没有元素您想在每个屏幕上保持相同,那应该不是问题。

在我看来, fragment 是完成几乎所有事情的更好方式。事实是,Fragments 对于初学者来说要复杂得多。因此,如果您有时间,请继续深入研究 Fragments,但如果您很着急,只需为每个屏幕调用一个 Activity 就适合这种情况。

关于java - 浏览屏幕 android 开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21941701/

相关文章:

java - 将本地对象数组复制到要由其他静态方法访问的实例化对象数组

java - Spring 3 MVC 应用程序中的 UTF-8 支持

android - 在上下文操作模式下选择时,ListView 项目在视觉上不会变为 "highlighted"

c# - 导航和 DI

android - androidx.fragment :fragment-ktx:1. 3.0-beta01 添加依赖导致运行时异常

java - 使用 servlet 与使用 jsp 打印 HTML。他们的优势是什么?

java - 记录 java outofmemoryerror stacktrace 控制台输出

html - 如何通过 CSS 打破溢出的导航栏

Android动态 fragment 加载进度条可见性不会设置

android - 如何直接与android ril daemon通信