我正在尝试创建一个表并向表中的列添加相同的空间。我的代码如下,但我的第二列没有与第一列相同的空间。就像您在我下面发布的图像中看到的那样,第一行(标题)与正文(第二行)没有相同的空间。
希望有人能帮助我了解这有什么问题

我想要的是

我的代码是:
<TableLayout
android:layout_width="match_parent"
android:layout_height="0dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" >
<TextView
android:layout_height="match_parent"
android:layout_weight="0.6" />
<ImageView
android:layout_height="wrap_content"
android:layout_weight="0.1"/>
<ImageView
android:layout_height="wrap_content"
android:layout_weight="0.1" />
<ImageView
android:layout_height="wrap_content"
android:layout_weight="0.1"" />
<ImageView
android:layout_height="match_parent"
android:layout_weight="0.1" />
</TableRow>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" >
<TextView
android:layout_height="0dp"
android:layout_weight="0.6" />
<ImageView
android:layout_height="0dp"
android:layout_weight="0.1" />
<ImageView
android:layout_height="0dp"
android:layout_weight="0.1" />
<ImageView
android:layout_height="0dp"
android:layout_weight="0.1" />
<ImageView
android:layout_height="0dp"
android:layout_weight="0.1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" >
<RelativeLayout
android:layout_height="wrap_content"
android:layout_weight="0.6" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout> …Run Code Online (Sandbox Code Playgroud) 我想将 png 图像放在按钮上,我尝试过 android:background 但 png 占据了所有按钮,我想要的正是像这样在按钮上使用徽标 png

信息徽标是我的 png,“关于”来自按钮文本
,这是我的 xml 代码
<RelativeLayout 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:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".Dashbored">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar">
</include>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tool_bar"
android:elevation="7dp"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/f_home_screen" />
</FrameLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#0284fe"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:itemBackground="@drawable/drawer_backg"
app:itemIconTint="@color/drawer_item"
app:itemTextAppearance="@style/NavDrawerTextStyle"
app:itemTextColor="@color/windowBackground"
app:menu="@menu/main_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我想像这样设置项目文本对齐中心
这是我的菜单 xml
<?xml version="1.0" encoding="utf-8"?><menu
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_inspec_rpt"
android:title="INSPECTION REPORTS"
/>
<item
android:id="@+id/nav_action"
android:title="ACTION ITEMS"
/>
<item
android:id="@+id/nav_appoint"
android:title="APPOINTMENTS" />
<item …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的片段:
在屏幕底部(底部导航栏的正上方)彼此相邻的粉红色圆点和灰色圆点的正上方,有一条水平灰线。
无论如何我可以删除它吗?
该片段具有以下布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".home.tutorial.TutorialFragment">
<android.support.v4.view.ViewPager
android:id="@+id/tutorialViewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/appBar"
android:background="@android:color/white"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
app:layout_constraintTop_toBottomOf="@id/tutorialViewPager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<me.relex.circleindicator.CircleIndicator
android:id="@+id/circleIndicator"
android:layout_width="match_parent"
android:layout_height="48dp"
app:ci_drawable="@drawable/tab_indicator_selected"
app:ci_drawable_unselected="@drawable/tab_indicator_default"
app:ci_height="6dp"
app:ci_width="6dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
</android.support.design.widget.AppBarLayout>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我看了这篇文章:删除操作栏边框
但考虑到我不想从操作栏中删除边框,我认为它不适用。
在具有多个主题的应用程序中,如何从样式文件更改 CardView 的背景颜色?
样式文件
<style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryTheme1</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkTheme1</item>
<item name="colorAccent">@color/colorAccentTheme1</item>
</style>
<style name="AppTheme2" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryTheme2</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkTheme2</item>
<item name="colorAccent">@color/colorAccentTheme2</item>
</style>
<style name="AppTheme3" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryTheme3</item>
<item name="colorPrimaryDark">@color/colorPrimaryDarkTheme3</item>
<item name="colorAccent">@color/colorAccentTheme3</item>
</style>
Run Code Online (Sandbox Code Playgroud)
卡片视图
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:elevation="4dp"
app:cardCornerRadius="15dp">
Run Code Online (Sandbox Code Playgroud)
我想更改每个主题的背景颜色,我希望在styles.xml 文件中完成此操作。
底部导航所选项目的颜色没有改变,尽管我提供了控制颜色变化的可绘制文件。我已经尝试了很多次,但我找不到代码中的错误。
请帮忙!
这是底部导航
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@color/bottomBackground"
app:itemTextColor="@drawable/icon_color"
app:itemIconTint="@drawable/icon_color"
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_navigation_menu"/>
Run Code Online (Sandbox Code Playgroud)
这是 icon_color
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccent" android:state_checked="true"/>
<item android:color="@color/grey" android:state_checked="false"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
编辑 :
当我删除这段代码时它工作正常
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
int id = menuItem.getItemId();
if(id == R.id.navigation_library) {
loadFragment(new LibraryFragment());
}
else if (id == R.id.navigation_for_you) {
loadFragment(new ForYouFragment());
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
为什么这段代码会干扰我的功能。
android android-layout android-xml bottomnavigationview material-components
我为我的应用程序设计了底部导航视图。这个想法很简单,绿色底部栏将有白色图标。我为此写了一个选择器
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:color="@android:color/white" />
<item android:color="@android:color/holo_blue_dark" />
</selector>
Run Code Online (Sandbox Code Playgroud)
它有效,它改变了图标颜色,但它并没有使其完全变成白色,颜色看起来呈灰色。我也尝试过,<item android:state_selected="true" android:color="@android:color/white" />但它也不起作用。我添加了下面的图片供您查看差异。
请帮忙
android android-xml android-bottomnav android-bottomnavigationview
我有一个问题.我从我的解析器类的结果中得到了ArrayList.那么我想把这个值(ArrayList中的值)放到TextView上.
这是我迄今为止所做的工作.我在main.xml上创建TextView
<TextView
android:id="@+id/deskripsi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
Run Code Online (Sandbox Code Playgroud)
在我的onCreate方法中,我初始化了文本视图
desk = (TextView)findViewById(R.id.deskripsi);
Run Code Online (Sandbox Code Playgroud)
然后我试图从谷歌地图和节点地标解析KML文件我把它的值放到ArrayList,这里我的代码
ArrayList<String> pathName = new ArrayList<String>();
Object[] objPlace;
//Parser Node Placemark
NodeList nlPlace = doc.getElementsByTagName("Placemark");
for(int p = 0; p < nlPlace.getLength(); p++){
Node rootPlace = nlPlace.item(p);
NodeList itemPlace = rootPlace.getChildNodes();
for(int y = 0; y < itemPlace.getLength(); y++){
Node placeStringNode = itemPlace.item(y);
NodeList place = placeStringNode.getChildNodes();
//valueName = nameList.item(0).getNodeValue().toString() + "+";
pathName.add(place.item(0).getNodeValue());
}
}
objPlace = pathName.toArray();
desk.setText("");
for (int j = 0; j < objPlace.length; j++){ …Run Code Online (Sandbox Code Playgroud)