Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
22febcbf
authored
7 years ago
by
罗翻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加自定义titlebar
parent
77d5a521
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
18 deletions
app/src/main/java/com/dayu/bigfish/ui/views/TitleBar.java
app/src/main/res/layout/activity_person_info.xml
app/src/main/res/layout/title_bar_layout.xml
app/src/main/res/values/attrs.xml
app/src/main/java/com/dayu/bigfish/ui/views/TitleBar.java
0 → 100644
View file @
22febcbf
package
com
.
dayu
.
bigfish
.
ui
.
views
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.TextView
;
import
com.dayu.bigfish.R
;
/**
* Created by luofan
* on 2018/2/6.
*/
public
class
TitleBar
extends
FrameLayout
{
private
boolean
isShowLeft
;
private
boolean
isShowRight
;
private
String
mTitleContent
;
private
String
mRightContent
;
private
TextView
mRightTitle
;
private
TextView
mTitle
;
private
View
mLeftTitle
;
public
TitleBar
(
@NonNull
Context
context
)
{
super
(
context
);
initView
(
context
,
null
);
}
public
TitleBar
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
initView
(
context
,
attrs
);
}
public
TitleBar
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
initView
(
context
,
attrs
);
}
private
void
initView
(
Context
context
,
AttributeSet
attrs
)
{
TypedArray
typedArray
=
context
.
obtainStyledAttributes
(
attrs
,
R
.
styleable
.
titleBar
);
isShowLeft
=
typedArray
.
getBoolean
(
R
.
styleable
.
titleBar_isShowLeft
,
true
);
isShowRight
=
typedArray
.
getBoolean
(
R
.
styleable
.
titleBar_isSowRight
,
true
);
mTitleContent
=
typedArray
.
getString
(
R
.
styleable
.
titleBar_title
);
mRightContent
=
typedArray
.
getString
(
R
.
styleable
.
titleBar_rightTitle
);
typedArray
.
recycle
();
View
view
=
View
.
inflate
(
context
,
R
.
layout
.
title_bar_layout
,
this
);
mRightTitle
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
tv_right
);
mTitle
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
tv_title
);
mLeftTitle
=
view
.
findViewById
(
R
.
id
.
tv_left
);
mTitle
.
setText
(
mTitleContent
);
mRightTitle
.
setText
(
mRightContent
);
if
(
isShowLeft
)
{
mLeftTitle
.
setVisibility
(
VISIBLE
);
}
else
{
mLeftTitle
.
setVisibility
(
GONE
);
}
if
(
isShowRight
)
{
mRightTitle
.
setVisibility
(
VISIBLE
);
}
else
{
mRightTitle
.
setVisibility
(
GONE
);
}
mLeftTitle
.
setOnClickListener
(
v
->
{
if
(
context
instanceof
Activity
)
{
((
Activity
)
context
).
finish
();
}
});
}
}
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/activity_person_info.xml
View file @
22febcbf
...
@@ -21,7 +21,8 @@
...
@@ -21,7 +21,8 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@color/cl_home_listview_bg"
android:background=
"@color/cl_home_listview_bg"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
android:visibility=
"visible"
>
<RelativeLayout
<RelativeLayout
android:id=
"@+id/title_idea"
android:id=
"@+id/title_idea"
...
@@ -38,10 +39,8 @@
...
@@ -38,10 +39,8 @@
android:onClick=
"@{()->presenter.dumpBack()}"
/>
android:onClick=
"@{()->presenter.dumpBack()}"
/>
<ImageView
<ImageView
android:layout_width=
"match_parent"
style=
"@style/card_line"
android:layout_height=
"@dimen/dp_6"
android:layout_alignParentBottom=
"true"
/>
android:layout_alignParentBottom=
"true"
android:src=
"@drawable/line_shape"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
...
...
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/title_bar_layout.xml
0 → 100644
View file @
22febcbf
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
style=
"@style/title"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_title"
style=
"@style/text_title"
/>
<ImageView
android:id=
"@+id/tv_left"
style=
"@style/title_image_back"
/>
<TextView
android:id=
"@+id/tv_right"
style=
"@style/title_right_text"
/>
<ImageView
style=
"@style/card_line"
android:layout_alignParentBottom=
"true"
/>
</RelativeLayout>
This diff is collapsed.
Click to expand it.
app/src/main/res/values/attrs.xml
View file @
22febcbf
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<declare-styleable
name=
"LRecyclerView"
>
<declare-styleable
name=
"LRecyclerView"
>
<attr
name=
"isReverse"
format=
"boolean"
/>
<attr
name=
"isReverse"
format=
"boolean"
/>
<attr
name=
"isRefreshable"
format=
"boolean"
/>
<attr
name=
"isRefreshable"
format=
"boolean"
/>
<attr
name=
"needCoreAdapter"
format=
"boolean"
/>
<attr
name=
"needCoreAdapter"
format=
"boolean"
/>
<attr
name=
"needFoot"
format=
"boolean"
/>
<attr
name=
"needFoot"
format=
"boolean"
/>
<attr
name=
"itemType"
format=
"reference"
/>
<attr
name=
"itemType"
format=
"reference"
/>
<attr
name=
"headType"
format=
"reference"
/>
<attr
name=
"headType"
format=
"reference"
/>
<attr
name=
"footType"
format=
"reference"
/>
<attr
name=
"footType"
format=
"reference"
/>
</declare-styleable>
</declare-styleable>
<attr
name=
"backgroundCard"
format=
"color"
/>
<attr
name=
"backgroundCard"
format=
"color"
/>
<attr
name=
"textColor"
format=
"color"
/>
<attr
name=
"textColor"
format=
"color"
/>
<attr
name=
"textColorBg"
format=
"color"
/>
<attr
name=
"textColorBg"
format=
"color"
/>
<attr
name=
"themeType"
format=
"string"
/>
<attr
name=
"themeType"
format=
"string"
/>
<attr
name=
"themeIcon"
format=
"reference"
/>
<attr
name=
"themeIcon"
format=
"reference"
/>
<attr
name=
"colorWhite"
format=
"color"
/>
<attr
name=
"colorWhite"
format=
"color"
/>
<declare-styleable
name=
"titleBar"
>
<attr
name=
"isShowLeft"
format=
"boolean"
/>
<attr
name=
"isSowRight"
format=
"boolean"
/>
<attr
name=
"title"
format=
"string"
/>
<attr
name=
"rightTitle"
format=
"string"
/>
</declare-styleable>
</resources>
</resources>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment