布局配色方案调整

0515
panqihua 4 years ago
parent 5ac2e79932
commit 440e47812c
  1. 21
      app/src/main/java/com/community/pocket/ui/main/MainFragment.java
  2. 17
      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 androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.navigation.NavController;
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) {
int color = ContextCompat.getColor(requireContext(), R.color.button_unchecked);
for (int id : buttonIds()) {
View v = requireActivity().findViewById(id);
v.setBackgroundColor(color);
}
if (view instanceof Button) {
Button button = (Button) view;
button.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorAccent));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
for (int id : buttonIds()) {
Button button = requireActivity().findViewById(id);
button.setTextAppearance(R.style.Button_unselect);
}
if (view instanceof Button) {
Button button = (Button) view;
button.setTextAppearance(R.style.Button_select);
}
}
}

@ -20,6 +20,7 @@ import androidx.lifecycle.MutableLiveData;
import com.community.pocket.R;
import com.community.pocket.data.main.info.InfoRequest;
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.ui.BaseFragment;
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++) {
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);
status.setVisibility(showStatus());
switch (forum.getStatus()) {
@ -95,11 +96,15 @@ public abstract class ForumPost extends BaseFragment {
//打开帖子
Button button = childView.findViewById(R.id.showAll);
button.setOnClickListener(v -> {
Intent intent = new Intent(getContext(), ForumDataActivity.class);
intent.putExtra(Param.forumId.name(), forum.getId());
startActivityForResult(intent, 1);
});
if (forum.getStatus() == ForumStatus.ok) {
button.setOnClickListener(v -> {
Intent intent = new Intent(getContext(), ForumDataActivity.class);
intent.putExtra(Param.forumId.name(), forum.getId());
startActivityForResult(intent, 1);
});
} else {
button.setVisibility(View.GONE);
}
layout.addView(childView);

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

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

@ -62,17 +62,6 @@
app:layout_constraintStart_toEndOf="@+id/headimg"
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
android:id="@+id/other_content"
android:layout_width="match_parent"

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

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

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

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

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

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

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

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

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

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

@ -1,40 +1,28 @@
<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">
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textSize">20sp</item>
</style>
<!-- 公告指示器未选中颜色-->
<style name="unselected_menu">
<item name="android:textColor">@color/colorBlack</item>
<item name="android:textSize">16sp</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- 按钮选中样式-->
<style name="Button_select">
<item name="android:background">@color/colorBlue</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:textSize">18sp</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.NoActionBar.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!--按钮未选中样式-->
<style name="Button_unselect">
<item name="android:background">@color/colorBlue</item>
<item name="android:textColor">@color/colorWhite</item>
<item name="android:textSize">16sp</item>
</style>
<style name="AppTheme.NoActionBar.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.NoActionBar.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>

Loading…
Cancel
Save