布局配色方案调整

0515
panqihua 5 years ago
parent 5ac2e79932
commit 440e47812c
  1. 11
      app/src/main/java/com/community/pocket/ui/main/MainFragment.java
  2. 7
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java
  3. 12
      app/src/main/res/layout/main/layout/forum/layout/form_titlebar.xml
  4. 1
      app/src/main/res/layout/main/layout/forum/layout/forum.xml
  5. 11
      app/src/main/res/layout/main/layout/forum/layout/forum_data_content.xml
  6. 1
      app/src/main/res/layout/main/layout/forum/layout/forum_list.xml
  7. 1
      app/src/main/res/layout/main/layout/forum/layout/forum_post_fragment.xml
  8. 1
      app/src/main/res/layout/main/layout/garbage/layout/garbage.xml
  9. 6
      app/src/main/res/layout/main/layout/garbage/layout/garbage_titlebar.xml
  10. 8
      app/src/main/res/layout/main/layout/info/layout/info_fragment.xml
  11. 1
      app/src/main/res/layout/main/layout/visitor/layout/visitor.xml
  12. 1
      app/src/main/res/layout/main/layout/visitor/layout/visitor_appointment_fragment.xml
  13. 9
      app/src/main/res/layout/main/layout/visitor/layout/visitor_titlebar.xml
  14. 2
      app/src/main/res/layout/titlebar_layout.xml
  15. 6
      app/src/main/res/values/colors.xml
  16. 36
      app/src/main/res/values/styles.xml

@ -5,7 +5,6 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.navigation.NavController; import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
@ -38,17 +37,17 @@ public abstract class MainFragment extends BaseFragment {
/** /**
* 点击按钮改变字体颜色 * 点击按钮改变字体颜色
*/ */
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
protected void changeColor(View view) { protected void changeColor(View view) {
int color = ContextCompat.getColor(requireContext(), R.color.button_unchecked); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
for (int id : buttonIds()) { for (int id : buttonIds()) {
View v = requireActivity().findViewById(id); Button button = requireActivity().findViewById(id);
v.setBackgroundColor(color); button.setTextAppearance(R.style.Button_unselect);
} }
if (view instanceof Button) { if (view instanceof Button) {
Button button = (Button) view; Button button = (Button) view;
button.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorAccent)); button.setTextAppearance(R.style.Button_select);
}
} }
} }

@ -20,6 +20,7 @@ import androidx.lifecycle.MutableLiveData;
import com.community.pocket.R; import com.community.pocket.R;
import com.community.pocket.data.main.info.InfoRequest; import com.community.pocket.data.main.info.InfoRequest;
import com.community.pocket.data.model.Forum; import com.community.pocket.data.model.Forum;
import com.community.pocket.data.model.ForumStatus;
import com.community.pocket.data.model.Page; import com.community.pocket.data.model.Page;
import com.community.pocket.ui.BaseFragment; import com.community.pocket.ui.BaseFragment;
import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity; import com.community.pocket.ui.main.ui.forum.data.ForumDataActivity;
@ -55,7 +56,7 @@ public abstract class ForumPost extends BaseFragment {
for (int i = 0; i < forumList.getList().size(); i++) { for (int i = 0; i < forumList.getList().size(); i++) {
final Forum forum = forumList.getList().get(i); final Forum forum = forumList.getList().get(i);
View childView = View.inflate(getContext(), R.layout.post, null); View childView = View.inflate(getContext(), R.layout.forum_list, null);
TextView status = childView.findViewById(R.id.check_status); TextView status = childView.findViewById(R.id.check_status);
status.setVisibility(showStatus()); status.setVisibility(showStatus());
switch (forum.getStatus()) { switch (forum.getStatus()) {
@ -95,11 +96,15 @@ public abstract class ForumPost extends BaseFragment {
//打开帖子 //打开帖子
Button button = childView.findViewById(R.id.showAll); Button button = childView.findViewById(R.id.showAll);
if (forum.getStatus() == ForumStatus.ok) {
button.setOnClickListener(v -> { button.setOnClickListener(v -> {
Intent intent = new Intent(getContext(), ForumDataActivity.class); Intent intent = new Intent(getContext(), ForumDataActivity.class);
intent.putExtra(Param.forumId.name(), forum.getId()); intent.putExtra(Param.forumId.name(), forum.getId());
startActivityForResult(intent, 1); startActivityForResult(intent, 1);
}); });
} else {
button.setVisibility(View.GONE);
}
layout.addView(childView); layout.addView(childView);

@ -7,11 +7,10 @@
<Button <Button
android:id="@+id/forum_hot" android:id="@+id/forum_hot"
style="?android:attr/buttonBarStyle" style="@style/Button_select"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/colorAccent"
android:text="@string/forum_hot" android:text="@string/forum_hot"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -19,11 +18,10 @@
<Button <Button
android:id="@+id/forum_new" android:id="@+id/forum_new"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/forum_new" android:text="@string/forum_new"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/forum_hot" app:layout_constraintStart_toEndOf="@id/forum_hot"
@ -31,11 +29,10 @@
<Button <Button
android:id="@+id/forum_post" android:id="@+id/forum_post"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/forum_post" android:text="@string/forum_post"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/forum_new" app:layout_constraintStart_toEndOf="@id/forum_new"
@ -43,11 +40,10 @@
<Button <Button
android:id="@+id/forum_my" android:id="@+id/forum_my"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/forum_my" android:text="@string/forum_my"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

@ -67,7 +67,6 @@
android:name="androidx.navigation.fragment.NavHostFragment" android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:defaultNavHost="true" app:defaultNavHost="true"
app:navGraph="@navigation/forum_navigation" /> app:navGraph="@navigation/forum_navigation" />
</LinearLayout> </LinearLayout>

@ -62,17 +62,6 @@
app:layout_constraintStart_toEndOf="@+id/headimg" app:layout_constraintStart_toEndOf="@+id/headimg"
app:layout_constraintTop_toBottomOf="@id/time" /> app:layout_constraintTop_toBottomOf="@id/time" />
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/other_content"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_marginTop="32dp"-->
<!-- android:background="@color/colorAccent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/headimg">-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<LinearLayout <LinearLayout
android:id="@+id/other_content" android:id="@+id/other_content"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -53,6 +53,7 @@
<Button <Button
android:id="@+id/showAll" android:id="@+id/showAll"
style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/open_content" android:text="@string/open_content"

@ -43,6 +43,7 @@
<Button <Button
android:id="@+id/post_button" android:id="@+id/post_button"
style="@style/Button_unselect"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:enabled="false" android:enabled="false"

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorAccent"
tools:context=".ui.main.ui.garbage.GarbageFragment"> tools:context=".ui.main.ui.garbage.GarbageFragment">
<include <include

@ -6,11 +6,10 @@
<Button <Button
android:id="@+id/garbage_sorting" android:id="@+id/garbage_sorting"
style="?android:attr/buttonBarStyle" style="@style/Button_select"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/colorAccent"
android:text="@string/garbage_sorting" android:text="@string/garbage_sorting"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -18,11 +17,10 @@
<Button <Button
android:id="@+id/garbage_waste" android:id="@+id/garbage_waste"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/garbage_waste" android:text="@string/garbage_waste"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/forum_hot" app:layout_constraintStart_toEndOf="@id/forum_hot"

@ -9,8 +9,7 @@
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:background="@color/colorAccent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -19,8 +18,7 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:background="#77A3C7">
<ImageView <ImageView
android:id="@+id/headimg" android:id="@+id/headimg"
@ -164,6 +162,7 @@
<Button <Button
android:id="@+id/open_modify_password" android:id="@+id/open_modify_password"
style="@style/Button_unselect"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_30" android:layout_marginTop="@dimen/size_30"
@ -171,6 +170,7 @@
<Button <Button
android:id="@+id/logout" android:id="@+id/logout"
style="@style/Button_unselect"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/action_logout" /> android:text="@string/action_logout" />

@ -32,7 +32,6 @@
android:name="androidx.navigation.fragment.NavHostFragment" android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorAccent"
app:defaultNavHost="true" app:defaultNavHost="true"
app:navGraph="@navigation/visitor_navigation" /> app:navGraph="@navigation/visitor_navigation" />
</LinearLayout> </LinearLayout>

@ -124,6 +124,7 @@
<Button <Button
android:id="@+id/submit" android:id="@+id/submit"
style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"

@ -7,11 +7,10 @@
<Button <Button
android:id="@+id/visitor_appointment" android:id="@+id/visitor_appointment"
style="?android:attr/buttonBarStyle" style="@style/Button_select"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/colorAccent"
android:text="@string/visitor_appointment" android:text="@string/visitor_appointment"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -19,11 +18,10 @@
<Button <Button
android:id="@+id/visitor_reservation" android:id="@+id/visitor_reservation"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/visitor_reservation" android:text="@string/visitor_reservation"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/forum_hot" app:layout_constraintStart_toEndOf="@id/forum_hot"
@ -31,11 +29,10 @@
<Button <Button
android:id="@+id/visitor_visitor" android:id="@+id/visitor_visitor"
style="?android:attr/buttonBarStyle" style="@style/Button_unselect"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/button_unchecked"
android:text="@string/visitor_visitor" android:text="@string/visitor_visitor"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/forum_new" app:layout_constraintStart_toEndOf="@id/forum_new"

@ -9,6 +9,7 @@
android:id="@+id/titlebar" android:id="@+id/titlebar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/colorBlue"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -16,6 +17,5 @@
app:leftType="textView" app:leftType="textView"
app:rightCustomView="@layout/titlebar_view" app:rightCustomView="@layout/titlebar_view"
app:rightType="customView" app:rightType="customView"
app:titleBarColor="#2CE1CF"
tools:leftText="@string/app_name" /> tools:leftText="@string/app_name" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -6,4 +6,10 @@
<color name="colorBlack">#000000</color> <color name="colorBlack">#000000</color>
<color name="button_unchecked">#00BCD4</color> <color name="button_unchecked">#00BCD4</color>
<color name="colorYellow">#FFEB3B</color> <color name="colorYellow">#FFEB3B</color>
<!-- 标题栏背景颜色-->
<color name="colorBlue">#2d87d2</color>
<!-- 按钮文字颜色-->
<color name="colorWhite">#FFFFFF</color>
</resources> </resources>

@ -1,40 +1,28 @@
<resources> <resources>
<!-- Base application theme. --> <!-- 公告指示器选中颜色-->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorAccent</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="selected_menu"> <style name="selected_menu">
<item name="android:textColor">@color/colorPrimary</item> <item name="android:textColor">@color/colorPrimary</item>
<item name="android:textSize">20sp</item> <item name="android:textSize">20sp</item>
</style> </style>
<!-- 公告指示器未选中颜色-->
<style name="unselected_menu"> <style name="unselected_menu">
<item name="android:textColor">@color/colorBlack</item> <item name="android:textColor">@color/colorBlack</item>
<item name="android:textSize">16sp</item> <item name="android:textSize">16sp</item>
</style> </style>
<style name="AppTheme.NoActionBar"> <!-- 按钮选中样式-->
<item name="windowActionBar">false</item> <style name="Button_select">
<item name="windowNoTitle">true</item> <item name="android:background">@color/colorBlue</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:textSize">18sp</item>
</style> </style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <!--按钮未选中样式-->
<style name="Button_unselect">
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <item name="android:background">@color/colorBlue</item>
<item name="android:textColor">@color/colorWhite</item>
<style name="AppTheme.NoActionBar.NoActionBar"> <item name="android:textSize">16sp</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style> </style>
<style name="AppTheme.NoActionBar.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.NoActionBar.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>

Loading…
Cancel
Save